googlearchive / TemplateBinding

TemplateBinding Prolyfill
290 stars 61 forks source link

Change ExpressionSyntax to use JS literal syntax rather than labelled statements #111

Closed rafaelw closed 10 years ago

rafaelw commented 11 years ago

e.g. instead of

<div val="{{ foo: bar; blaz: bat; }}">

something like

<div val="{{ { foo: bar, 'blaz': bat } }}">

I think the triple curlies are kinda ugly, but it does make more sense. Also, note all class values are valid identifiers, so this is strictly more correct.

krisnye commented 11 years ago

I agree that you should use commas, but we shouldn't confuse object literals with labelled expressions. Just use double brackets for labeled expressions and triple only for object literals which will be more rare.

Labeled expression:

<div class="{{ foo:bar, blaz: bat }}">

Object literal:

<my-class my-attribute="{{{foo:bar, blaz: bat }}}">

Array literal:

<my-class my-items="{{[1,2,true,"foo"]}}">

My naive assumption was that ANY valid JSON expression would also be a valid MDV expression.

rafaelw commented 11 years ago

Just be clear, I'm suggesting ditching labeled statements in favor of object literals.

krisnye commented 11 years ago

In that case, I would still recommend the triple bracket syntax for object literals so that all JSON expressions are valid MDV expressions.

rafaelw commented 10 years ago

This is now done. We have yet to remove labelled statements: https://github.com/Polymer/polymer-expressions/issues/9, but that will wait on having registration for filters finished and default filters which handle the class/style use-case