machty / emblem.js

Emblem.js - Ember-friendly, indented syntax alternative for Handlebars.js
http://emblemjs.com
MIT License
1.04k stars 81 forks source link

Attribute converted to string #264

Closed rmzr7 closed 6 years ago

rmzr7 commented 8 years ago

Doing something like

          select
            each months as |month|
              option selected={{isAdmin}} value=month {{month}} month

Would result in

NuckChorris commented 8 years ago

My understanding is that

select
  each months as |month|
    option selected={{isAdmin}} value=month {{month}} month

compiles to

<select>
  {{#each months as |month|}}
    <option>selected={{isAdmin}} value=month {{month}} month</option>
  {{/each}}
</select>

It seems that Emblem cannot handle properties without quotes, so the modern onclick={{action}} style is also not usable. The Emblem.js parser generator needs some love I think

thec0keman commented 8 years ago

I believe the issue is the use of double mustache. Emblem's syntax for explicit mustache is using the single syntax (e.g. { isAdmin }).

That being said, Emblem is very smart about handling bound attributes. So for example, these have identical output:

    option selected=isAdmin value=month #{month} month
    option selected={ isAdmin } value={ month } #{month} month

(Note also the use of #{} for in-string mustache).

As for actions, especially after 0.8 you can use pretty much any action / subexpression inside single mustache. For some examples, see these tests.