EGL: How to send a sequence as a parameter to a template [message #1736255] |
Mon, 27 June 2016 22:07 |
Alireza Rouhi Messages: 148 Registered: December 2015 |
Senior Member |
|
|
Hi,
I have an EGL template which generates a list of transformation rules.
So, I would like to send a sequence of elements as a parameter to apply in the generated rules in the template (in the target .egx file).
For example:
My .egl file is as follows:
[% var s = Sequence {"first", "second", "third"};
var i: Integer = 0;
while (i < 2) { %]
rule generate[%= i %]
transform s : SourceModel!Type {
parameters {
var params : new Map;
params.put("s", [%= s %]);
return params;
}
template : "template.egl"
target : "target.txt"
}
[%
i = i + 1;
}
%]
and the generated .egx file is as follows:
rule generate0
transform s : SourceModel!Type {
parameters {
var params : new Map;
params.put("s", [first, second, third]); // erroneous
return params;
}
template : "template.egl"
target : "target.txt"
}
rule generate1
transform s : SourceModel!Type {
parameters {
var params : new Map;
params.put("s", [first, second, third]); // erroneous
return params;
}
template : "template.egl"
target : "target.txt"
}
Is there any way to resolve this issue?
Best regards,
Alireza
|
|
|
|
|
Re: EGL: How to send a sequence as a parameter to a template [message #1736286 is a reply to message #1736278] |
Tue, 28 June 2016 09:03 |
|
A nested sequence will be trickier, of course. If you have a bounded number of nesting levels (say, sequence of sequence of integers) you could use different separators, say "," for first level and ";" for second level. Maybe something like:
var nested = stringParam.split(",").asSequence().collect(e|e.split(";").asSequence()).asSequence();
That splits by ",", and then splits again by ";".
|
|
|
|
Powered by
FUDForum. Page generated in 0.04579 seconds