[stringtemplate-interest] Cannot get $elseif(condition)$ to work
Crack Babylon
crackbabylon at gmail.com
Wed Feb 22 02:37:53 PST 2012
Greetings,
I am currently working on a DSPF to Java transformation. When constructing
my *.stg template file I am struggling to find out why my template code is
not working and I am not finding relevent answers in Google or the ST
website. The error I get is as follows:
"java.lang.
IllegalArgumentException: Can't find template elseif.st; context is
[dspfScreenMain anonymous if(it.subfile)_subtemplate]"
I am iterating through a List of objects and each of these objects can be
of type SUBFILE, SUBFILE_CONTROL or STANDARD. So to sort these out I need
to do an elseif and I cannot get the $elseif$ working.
My code is as follows:
$dspfScreen.screenRecords:{
$if(it.subfile)$
FOUND SUBFILE - output sub file inner class
$elseif(it.subfileCtrl)$
FOUND SUBFILE CONTROL - output subfile control inner class
$else$
FOUND STANDARD - output standard record inner class
$endif$
With this code I get the error as explained above. If I remove the
$elseif(x)$ I have no problem but I really need to test for multiple things
and this won't be the only time I need to do it. So I was wondering why I
get the error and why is my code wrong?
I know there are many ways to skin this cat, I could sort these objects in
my Java class and iterate through each of the sorted Lists but being able
to use the $esleif$ would be handy.
Cheers for any help and advice you can give :)
Thanks
Big Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20120222/f41eaf1e/attachment.html
More information about the stringtemplate-interest
mailing list