Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Forcing an new line EGL
Forcing an new line EGL [message #872624] Wed, 16 May 2012 13:36 Go to next message
Maarten Bezemer is currently offline Maarten BezemerFriend
Messages: 117
Registered: February 2012
Senior Member
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 13:37]

Report message to a moderator

Re: Forcing an new line EGL [message #872674 is a reply to message #872624] Wed, 16 May 2012 15:20 Go to previous messageGo to next message
Horacio Hoyos is currently offline Horacio HoyosFriend
Messages: 165
Registered: October 2009
Senior Member

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,
Re: Forcing an new line EGL [message #877106 is a reply to message #872674] Fri, 25 May 2012 22:13 Go to previous message
Horacio Hoyos is currently offline Horacio HoyosFriend
Messages: 165
Registered: October 2009
Senior Member

Section 7.6 of the Epsilon book talks about formatters and how to use them from within EGL!
Previous Topic:Question on multiple validators (for the same object) and fixes
Next Topic:Problem using Epsilon Unit Testing Framework
Goto Forum:
  


Current Time: Wed Dec 07 20:34:54 GMT 2016

Powered by FUDForum. Page generated in 0.18791 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software