Closure Templates handles row concatenation as follows:
Inside the template, you can backslide the lines as much as you want, because the template compiler removes all line terminators and spaces at the beginning and end of lines, including spaces preceding the comment of the rest of the line. The compiler completely removes empty lines that consist only of spaces. Sequential lines are concatenated according to the following heuristics: if the connection location borders a template or HTML tag on both sides, the lines are concatenated without a space . If the connection location does not limit the template or HTML tag on both sides, the lines are concatenated with one space.
To add a space in Closure Templates, where necessary, use the special character command {sp}
. In the event that unwanted space is inserted, you can delete it using the {nil}
command. For string connection examples, see features.soy .
simple.soy will become:
{namespace examples.simple} {template .hiWorld} Hello{sp} {if $name} {$name}! {else} world! {/if} {/template}
source share