Desmond Hume
Desmond Hume

Reputation: 8607

Make Smarty ignore white space up to the next statement

In a Smarty template, is there a way to make Smarty ignore white space between two statements in a logically structured code with lots of indentations, so that the resulting HTML wouldn't contain it? A practical usage would be to avoid white space between two links, since links that go in a chain would be displayed differently depending on the presence of white space in between them. I would imagine it like this:

<a href="">A link</a>{ignore_whitespace_up_to_next_statement_please}
{if $var == "something"}{ignore_whitespace_up_to_next_statement_please}
  <a href="">Another link</a>
{/if}

which would produce this HTML output:

<a href="">A link</a><a href="">Another link</a>

Upvotes: 1

Views: 247

Answers (1)

rodneyrehm
rodneyrehm

Reputation: 13557

there is the {strip} block you could use. Otherwise I'd suggest using the outputfilter trimwhitespace (or a derivation of it).

Upvotes: 2

Related Questions