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] <javascript:>> 
> 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] <javascript:>.
>> 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] <javascript:>> 
> 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] <javascript:>.
>> 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] <javascript:>> 
> 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] <javascript:>.
>> 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.
For more options, visit https://groups.google.com/d/optout.
Title: _expression_ Test

Reply via email to