Hmm... I'm afraid you've gone beyond my limited knowledge of
PolymerExpressions here.

There must be some magic to get the global filters to work outside of a
Polymer element, but I don't know what it is.

You can create a local dictionary of filters, and pass that in as the
filterRegistry (third argument to getValue).

Example:

http://jsbin.com/rimila/2/edit

It might work differently if you were importing PolymerExpressions
directly, instead of importing Polymer... But I'm speculating here. I've
only used and documented Polymer expressions in the context of Polymer data
binding.

OK
Arthur


On Wed, Feb 4, 2015 at 6:58 PM, <[email protected]> wrote:

> Thanks yes you are correct :)
>
> Was hoping to ask one other question related to this. I am attempting to
> add a global filter (
> https://www.polymer-project.org/docs/polymer/expressions.html#writing-global-filters)
> and use it in my expression as show below. However if I add a filter it
> produces an error Uncaught TypeError: Cannot read property 'lowercase' of
> undefined. It does seem to register the filter and I can use it via html
> but not via JavaScript.  Any suggestion on what I am doing wrong or how to
> use a custom filter like this?
>
> Thanks again for the help
>
> <!DOCTYPE html>
> <html lang="en-US">
> <head>
>     <title>Expression Test</title>
>     <script src="
> http://www.polymer-project.org/components/webcomponentsjs/webcomponents.js
> "></script>
>     <link rel="import" href="
> http://www.polymer-project.org/components/polymer/polymer.html";>
> </head>
> <body>
>     <script language="JavaScript">
>         PolymerExpressions.prototype.lowercase = function(input){
>      return input.toLowerCase();
> };
>
>         if(PolymerExpressions.getExpression('2 * 3 + X > 2').getValue({
> 'X': 44444 })) {
>             alert("hit")
>         };
>
>         alert(PolymerExpressions.getExpression("ABC |
> lowercase").getValue({}))
>     </script>
> </body>
>
>
>
> On Tuesday, February 3, 2015 at 3:06:40 PM UTC-5, arthure wrote:
>>
>> 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.
>>>
>>
>>
> On Tuesday, February 3, 2015 at 3:06:40 PM UTC-5, arthure wrote:
>>
>> 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.
>>>
>>
>>
> On Tuesday, February 3, 2015 at 3:06:40 PM UTC-5, arthure wrote:
>>
>> 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/4863dac3-ba2e-47c8-b452-470ffb47023e%40googlegroups.com
> <https://groups.google.com/d/msgid/polymer-dev/4863dac3-ba2e-47c8-b452-470ffb47023e%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_wkZQbxXFy70niP%2BHByJpihUOxUkz3keF96Ng_p8JOZsQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to