|Re: Post trim not working [message #1765947 is a reply to message #1765385]
||Wed, 14 June 2017 14:39
|| Laurent Goubet
Registered: July 2009
"trim" will remove the spaces "around" the result of your template call, not all spaces inside it; there are no such white spaces in your trimBeforeWrite template.
The whitespaces you see are the ones added by your for loop, specifically the carriage return after ";". You could remove that carriage returns by having the end of your for loop on the same line:
[for(a : Property | c.attribute)]
LIkewise, the carriage return before "bla" is the one inside your "if", and you'd need to remove it as well:
[if (2 < 3)]
Blablubs: [c.name/] foo[else]
This is probably not the answer you wanted, but we made the choice to preserve these particular line endings as significant in the template writing, so you need to work around them if you happen not to want them generated.
Note that you could use something other than "trim" if you want to remove all line separators from the template call, regardless of their position (i.e. also the ones "in the middle" of the text generated by the template.
For example, replace could work for your case:
[template public trimBeforeWrite(c : Class) post (replace('\\\\s', ''))]
would remove "all" whitespace.
[template public trimBeforeWrite(c : Class) post (replace('\\\\r|\\\\n', ''))]
would remove the line endings.
Powered by FUDForum
. Page generated in 0.02104 seconds