[stringtemplate-interest] How to use variables inside format modifiers
Jim Idle
jimi at temporal-wave.com
Fri Jul 31 11:41:26 PDT 2009
Mohamed Mansour wrote:
> Hmm, that would be unfortunate. I can't use this kind of approach
> then. I am trying to create a generic "Report" where every user can do
> whatever they want with it. If they wanted to add 10 to the result to
> any variable, they could. But we can't do that with StringTemplate.
>
> I guess that is the limitation of StringTemplate.
>
> Isn't there any way I can make it work, like a hack? A user can modify
> a variable by appending(adding) a number to it. (simply scenario)
There is always a hack for everything, but if you can pass in the + and
so on to the template then why can you not do this in the model rather
than the view?
However, you could first pass in the values via other invocations that
return "" and store them in static variables in your renderer, then
invoke a format="calculate". Total hack and violation of the idea of
course, but I suppose that so long as you know this and comment it as
such, then it is up to you:
$numa;format="storeOp1"$$numb;format="add"$
Or something similar.
Jim
More information about the stringtemplate-interest
mailing list