[Acceleo ]ECORE Loop over References [message #791862] |
Mon, 06 February 2012 10:46  |
Kalaus Schaefersen Messages: 2 Registered: February 2012 |
Junior Member |
|
|
Hi,
my M2T templates are based on ECORE and I'd like to write a simple template the copies the values of an object into an array (php). To do so, I need the current index of the for loop. In Acceleo 2.x there was a a current() function, but I could not find anything similar in Acecleo 3.x
My template code looks like:
[for (ref : EReference | e.eReferences)]
$result['['/] X [']'/] = ... // TODO write instead of X the current index
[/for]
The result should look like
$result[0] = ...
$result[1] = ...
This gives me also an warning in the eclipse. Is teher a better way to loop over the refs? For the eAttributes this seems to be fine.
By the way, is there a smarter way to print "[" or "]"s?
THX,
Kalaus
[Updated on: Tue, 07 February 2012 09:00] Report message to a moderator
|
|
|
|
|
|
Re: [Acceleo ]ECORE Loop over References [message #808930 is a reply to message #791862] |
Tue, 28 February 2012 09:53  |
|
Kalaus,
Do you really need to iterate through two different loops over attributes and references? You could use a loop on eAllStructuralFeatures instead and not worry about the index.
[for (feature : EStructuralFeature | e.eAllStructuralFeatures())]
$result['['/] [i/] [']'/] = ...
[/for]
Laurent Goubet
Obeo
|
|
|
Powered by
FUDForum. Page generated in 0.02252 seconds