I think you want getValue:
var myExpression = PolymerExpressions.getExpression("2 + 2 * 5");
var result = myExpression.getValue({ x: 5 }, undefined, {});
You'll also need observe-js, which defines the Path object:
https://github.com/Polymer/observe-js/blob/master/README.md
On Mon, Feb 2, 2015 at 8:21 AM, <[email protected]> wrote:
> Good Day All,
>
> I am building an API that needs to evaluate expressions outside of the
> normal web view (configuration file). I was hoing to use the
> polymer-expression code to manually evaluate expressions defined in a JSON
> configuration file and apply a model / context. I have got a sample working
> as long as I do not add any context variables to it
>
> By doing
> ...
>
> <script src="/javascript/esprima.js"></script>
> <script src="/javascript/polymer-expressions.js"></script>
>
> var myExpression = PolymerExpressions.getExpression("2 * 3 + 2");
> var result = myExpression.expression();
>
> ...
>
> However how would I go about passing a model/context so I can evaluate
> against variables using this manual process?, Not sure what I am doing
> wrong any help pointing me in the right direction would be appreciated
>
> var model = { X: 1 };
> var myExpression = PolymerExpressions.getExpression("2 * 3 + X");
> var result = myExpression.expression(model);
>
> Thanks
>
> Ashley
>
>
> Follow Polymer on Google+: plus.google.com/107187849809354688692
> ---
> You received this message because you are subscribed to the Google Groups
> "Polymer" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/polymer-dev/fc02130e-4c15-48aa-a35a-b803e84b8660%40googlegroups.com
> <https://groups.google.com/d/msgid/polymer-dev/fc02130e-4c15-48aa-a35a-b803e84b8660%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups
"Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/polymer-dev/CADSbU_z_ka-u_RnH_OSnA1aH_NkjkKg_G2r_ZZk8zQZKVb1BMA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.