Skip to main content



      Home
Home » Modeling » M2T (model-to-text transformation) » Text Production Rules(Indentation in output)
Text Production Rules [message #686515] Wed, 22 June 2011 08:03 Go to next message
Eclipse UserFriend
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 08:07] by Moderator

Re: Text Production Rules [message #686595 is a reply to message #686515] Wed, 22 June 2011 11:04 Go to previous message
Eclipse UserFriend
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 May 15 09:27:03 EDT 2025

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

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

Back to the top