Struct hcl::format::FormatterBuilder
source · pub struct FormatterBuilder<'a, W> { /* private fields */ }
Expand description
A builder to create a Formatter
.
See the documentation of Formatter
for a usage example.
Implementations
sourceimpl<'a, W> FormatterBuilder<'a, W>
impl<'a, W> FormatterBuilder<'a, W>
sourcepub fn indent(self, indent: &'a [u8]) -> Self
pub fn indent(self, indent: &'a [u8]) -> Self
Set the indent for indenting nested HCL structures.
The default indentation is two spaces.
sourcepub fn dense(self, yes: bool) -> Self
pub fn dense(self, yes: bool) -> Self
If set, blocks are not visually separated by empty lines from attributes and adjacent blocks.
Default formatting:
attr1 = "value1"
attr2 = "value2"
block1 {}
block2 {}
Dense formatting:
attr1 = "value1"
attr2 = "value2"
block1 {}
block2 {}
sourcepub fn compact(self, yes: bool) -> Self
pub fn compact(self, yes: bool) -> Self
If set, arrays and objects are formatted in a more compact way.
See the method documation of compact_arrays
and
compact_objects
.
sourcepub fn compact_arrays(self, yes: bool) -> Self
pub fn compact_arrays(self, yes: bool) -> Self
Controls the array formatting.
By default, array elements are separated by newlines:
array = [
1,
2,
3,
]
When compact array formatting is enabled no newlines are inserted between elements:
array = [1, 2, 3]
sourcepub fn compact_objects(self, yes: bool) -> Self
pub fn compact_objects(self, yes: bool) -> Self
Controls the object formatting.
By default, object items are separated by newlines:
object = {
one = "foo"
two = "bar"
three = "baz"
}
When compact object formatting is enabled no newlines are inserted between items:
object = { one = "foo", two = "bar", three = "baz" }