Ember JS eval helper
This addon introduce e
(eval) helper, to allow this syntax usage in templates:
eval
.
<button {{action (e "alert") "Hello" target=(e "window") }}>
onclick = window.alert("hello")
</button>
{{#let (e "{ projectName: 'Ember' }") as |project|}}
<h2 id="title">{{project.projectName}}</h2>
{{/let}}
{{#each (e "[1,2,3,4]") as |item|}}
Number: {{item}}
{{/each}}
this
scope access also supported, passing it as second argument
export {
name: "foo"
}
{{e 'this.name' this}}
Manual this
context creation:
<MyComponent
@params={{
e "this.onClick(this.foo, this.bar)"
(hash
onClick=(e "this.onClick.bind(this)" this)
foo=@foo
bar=(array 1 2 3)
)
}}
></MyComponent>
Sugar: Angle components tagged values will be autocompiled.
// input
<MyComponent @name="`this.realName()`" ></MyComponent>
// output
<MyComponent @name={{e 'this.realName()' this}}>
ember install ember-eval-helper
helper e(evalString = '', context = null)
<Component @attr="`someTextToEval`" ></Component>
See the Contributing guide for details.
This project is licensed under the MIT License.