Forcing an new line EGL [message #872624] |
Wed, 16 May 2012 09:36  |
Eclipse User |
|
|
|
I'd like to generate a new line in EGL at the end of a @template operation, but I seem to fail no matter what I try:
[%
@template
operation MyObject doSomething() {
if(test) {
%]my text[%
} else {
%]my other text[%
}
-- Problem is with this new line:
%]
[%
}
%]
I also tried multiple enters (after the if statement), a [%=out.println()%] or a [%=out.println("\n")%].
In all situations the the new lines are ignored.
If I add a space before the [% ( the one after the new line problem) it works without a problem, but I do not want a space (or anything else) there...
Are there any solutions for this 'problem'?
[Updated on: Wed, 16 May 2012 09:37] by Moderator
|
|
|
Re: Forcing an new line EGL [message #872674 is a reply to message #872624] |
Wed, 16 May 2012 11:20   |
Eclipse User |
|
|
|
Maarten,
In general (in my experience) M2T languages suffer from couple of restrictions/limitations on how "fine" you can make the generated text look. As a rule of thumb, I personally, focus on the template code to be readable, regardless if the outcome is pretty or not. If the generated text definitely needs to be "pretty" you can create a "pretty printer" which basically is a text parser that takes care of indenting, putting brackets in a new line, making sure empty brackets have a line in between, and such. I know it is probably additional work but as I said, I prefer an understandable template (something I can explain and something others can use and modify/fix) than a beautiful generated code. And at the end of the day u can make the pretty printer once and use it multiple times. I guess using text parsing specific applications would make the job much easier (I have used one in the past but atm I cant recall the name).
Regards,
|
|
|
|
Powered by
FUDForum. Page generated in 0.03767 seconds