[stringtemplate-interest] List-making problem
Mikael Nyberg
mikaeln at acm.org
Fri Nov 21 04:05:37 PST 2008
I really like the ideas behind StringTemplate, MVC separation,
avoiding ad hoc processing in the view etc It's a real shift of
thinking after working with increasingly powerful view engines. But
now I'm stuck with something I think I should be able to do but after
a bit of effort still can't - help would be greatly appreciated. I
need to create "advanced search"-type queries of the form
and( where:"oslo" , what:"diving equipment" ) based on attributes
where and what, both of which may not be present (and there's more of
them, just using these two as an example). if $if(where)$ evaluates to
false/empty, I would like the list
and( what:"diving equipment" )
I keep the templates in a group file, so there would be a parameterless template
advancedSearch() ::= <<
>>
that would create the query, probably using subtemplates. Problem is:
I cannot find a way to handle creating the comma separator. My initial
idea was to use the list-making construct $[a,b,c] ;separator=","$,
but that construct does not help creating where:"oslo" from the
attribute where with value "oslo". I.e.
$[where:{where:$it$},what:{what:$it$}];separator=","$] is not legal.
I've tried lots of other things as well, most of them also too
embarassing to reproduce here.
Is there a violation of principles here, or am I just missing
something in the language?
Thanks,
-Mikael
--
Mikael Nyberg
mikaeln at acm.org
More information about the stringtemplate-interest
mailing list