I've run into a problem where defining the value of a {block}
introduces a lot of unnecessary whitespace.
I've a main template, let's call it main.html
, which looks like this (simplified):
<html>
<title>{block name=title}{$default_title}{/block}</title>
...
</html>
Then I inherit from it in let's say topics.html
, and I define the title block in it:
{extends file="main.html"}
{block title}
{if $topic}
{if $topic == "all"}
{eval $Config['titles']['topics']['all']}
{else}
{eval $Config['titles']['topics']['particular']}
{/if}
{else}
{eval $Config['titles']['topics']['list']}
{/if}
{/block}
Now when I compile the topics.html
template, there is so much whitespace inside of <title>...</title>
tag.
For example, it looks like this:
<title>
Showing all wiki topics </title>
How could I trim/strip the whitespace from the result of evaluating a block so it looked like the following:?
<title>Showing all wiki topics</title>
I tried adding {strip}...{/strip}
around the {block title}...{/block}
like this:
{strip}
{block title}
...
{/block}
{/strip}
But that didn't change anything.
I also tried this:
{block title|strip}
...
{/block}
But that was a syntax error. I also tried this:
{block title|trim}
...
{/block}
But it also was a syntax error.
I also tried:
{block title}
{strip}
...
{/strip}
{/block}
But that didn't help either as I already introduced a new-line after {block title}
so it stays there in the compiled template.
Any help appreciated!