Skip to main content

indent

Function indent 

Source
pub fn indent(
    value: StringInput<'_>,
    width: Option<usize>,
    indent_first_line: Option<bool>,
    indent_blank_lines: Option<bool>,
    kwargs: Kwargs,
) -> Result<Value, Error>
Expand description

Indents a value with spaces.

The first optional parameter to the filter can be set to true to indent the first line. The parameter defaults to false. The second optional parameter to the filter can be set to true to indent blank lines. The parameter defaults to false. This filter is useful if you want to template YAML files.

example:
  config:
{{ global_config|indent(2) }}          # does not indent first line
{{ global_config|indent(2,true) }}     # indent whole Value with two spaces
{{ global_config|indent(2,true,true)}} # indent whole Value and all blank lines

The parameters can also be provided as keyword arguments for compatibility with Jinja2: width, first, and blank.

{{ global_config|indent(width=4, first=true, blank=false) }}