trim, ltrim, rtrim, notrim

Syntax

[#trim]
or
[#ltrim]
or
[#rtrim]
or
[#notrim]

Description

These directives instruct the engine to ignore certain whitespace characters in the line of the tag:

trim Ignore all leading and trailing whitespace in this line.
ltrim (for left trim) Ignore all leading whitespace in this line.
rtrim (for right trim) Ignore all trailing whitespace in this line.
notrim This directive disables whitespace stripping in the line where it occurs. It also disables the effect of other trim directives occurring in the same line (the effect of trim, rtrim, ltrim).

where:

It is important to understand that these directives examine the template itself, and not the text output the template generates. (That is, the whitespace removal happens at parse time and not at runtime.)

The placement of these directives inside the line has no importance. That is, the effect will be the same regardless if you put the directive at the beginning of the line, or at the end of the line, or in the middle of the line.

The trim, ltrim and rtrim let you write more readable templates without impact on the generated code: you can format the template the way you want and control precisely what whitespaces are to be ignored.

Examples

Notation used in the following examples:

trim

----
··Hello[#trim]
  World
----

----
Hello  World
----

ltrim

----
··Hello[#ltrim]
  World
----

----
Hello
  World
----

rtrim

----
  Hello[#rtrim]
  World
----

----
  Hello  World
----