OctopusDeploy / Octostache

| Public | The variable substitution syntax for Octopus Deploy
Other
5 stars 24 forks source link

Add indent filter #58

Closed rhysparry closed 3 years ago

rhysparry commented 3 years ago

The indent filter can be used to indent text.

By default, with no options it will add an indent of four spaces to each line.

By supplying a single integer parameter between 0 and 255 you can adjust the number of spaces each line is indented by. For example:

  #{variable | Indent 2 }

Will indent each line by two spaces.

If the first line needs to be indented by a different amount you can use the following syntax:

  #{variable | Indent 2/4 }

This will indent the first line with two spaces, and subsequent lines with four spaces.

If you don't want to indent the first line you can omit the first number like so:

  #{variable | Indent /4 }

This will indent all lines except the first.

The maximum size of a space indent is 255.

If indenting other than spaces is required you can supply the string to prefix each line. For example:

  #{variable | Indent "// " }

This will put // at the beginning of each line.

To specify a different indent for initial/subsequent lines, pass two options:

  #{if variable}/* #{variable | Indent "" " * "}
   */#{/if}

This uses an empty string in the first line and * in subsequent lines, generating a multi-line block comment.

To include hashes in the indent, you need to use the escaped quoted text format:

  #{variable | Indent \\"# \\"}