Discussion:
Evaluate a mathematical expression for substitution
Brian H
2010-02-05 17:25:54 UTC
Permalink
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?
--
You received this message because you are subscribed to the Google Groups "JSON Template" group.
To post to this group, send email to json-template-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to json-template+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/json-template?hl=en.
Loading...