Evaluate a mathematical expression for substitution

18 views
Skip to first unread message

Brian H

unread,
Feb 5, 2010, 12:25:54 PM2/5/10
to JSON Template
I am experimenting with json-template, PHP implementation.

In my application, I have the need to perform simple mathematical
expression evaluation in the template. Example:

{.repeated section rows}
<Row xpos="10" ypos="{.eval @index*33+53}" />
{.end}

Of course, there is no such token as "eval." If there was such a
thing, I simply want to use it to perform these kind of simple
calculations, normally including the value of either {@} or {@index}.

This seems like a basic enough use-case that it may have come up
before. Is this sort of functionality totally missing from json-
template? Is there a better way to implement, perhaps using
"formatters?"

Thanks for any advice.

-Brian

P.S. Anybody thinking about a C++ port?

Reply all
Reply to author
Forward
0 new messages