Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Text Production Rules(Indentation in output)
Text Production Rules [message #686515] Wed, 22 June 2011 12:03 Go to next message
Dharam  is currently offline Dharam Friend
Messages: 18
Registered: December 2010
Junior Member
Hello,

Problem : How to avoid spaces, leading & trailing white spaces, new line chars in template?

As you can see in below example, 1 template is calling/using another template. In main template before emitting text [findAssoc(...)/] , there are only 2 tabs. And included template has 5 tabs before emitting text.

In both of that I have used post(trim()) to avoid that. But still output appears at 7 tabs from left margin. How should I ask to take "only text emitted by another template" , when I am using 1 template from another template.

Snippet,



index.php/fa/3091/0/

index.php/fa/3092/0/

[Updated on: Wed, 22 June 2011 12:07]

Report message to a moderator

Re: Text Production Rules [message #686595 is a reply to message #686515] Wed, 22 June 2011 15:04 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Hi Dharam,

"trim()" removes the leading and trailing spaces from a given String. In your case, the tab that will be removed by the "post(trim())" of findAssoc is the very first tab (which is located on line 6 of the PatternGen module). In that case, trimming won't help you.

These are the only ways I see to fix the issue :


  • Rethink the indentation of the findAssoc template
  • Change the line
    <tabs>:[ref.name/]
    so that it is trimmed :
    [('<tabs>' + ':' + ref.name).trim()/]

  • Use post(replaceAll('\\n(\\t*)', '\\n')) to manually remove all tabulations from the beginning of each lines of that templates' output (not recommended for readability or if you may need traceability on that module)
  • Split findAssoc in two so that the offending line is the first line actually generating text of one template on which you could call "post(trim())"


There isn't much that can be done here. Acceleo focuses more on the indentation of the generated text than on the indentation of the modules themselves.

Laurent Goubet
Obeo
Previous Topic:[Acceleo3.1] @generated NOT
Next Topic:[Xpand] Query regarding Extension (.ext) file
Goto Forum:
  


Current Time: Thu Apr 18 06:31:57 GMT 2024

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

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

Back to the top