|
Re: Post trim not working [message #1765947 is a reply to message #1765385] |
Wed, 14 June 2017 10:39  |
Eclipse User |
|
|
|
Hi,
"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)]
Whatevertype [a.name/];[/for]
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]
BingBong![/if]
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.
Laurent Goubet
Obeo
|
|
|
Powered by
FUDForum. Page generated in 0.03741 seconds