I’ve created a new app by
ember new my-app
The helper file my-app\app\helpers\highlight.js
import Ember from 'ember';
export default Ember.Handlebars.helper('highlight', function(value , options) {
var escaped = Handlebars.Utils.escapeExpression(value);
return new Ember.Handlebars.SafeString('<span class="highlight">' + escaped + '</span>');
});
/*export default Ember.Handlebars.makeBoundHelper(function(value, options) {
var escaped = Handlebars.Utils.escapeExpression(value);
return new Ember.Handlebars.SafeString('<span class="highlight">' + escaped + '</span>');
});*/
is used like
my-app\app\templates\about.hbs
<h1>About</h1>
{{highlight 'About'}}
Without the commented out line in my-app\app\index.html
...
{{content-for 'body'}}
<!--<script type="text/javascript" src="http://cloud.github.com/downloads/wycats/handlebars.js/handlebars-1.0.0.beta.6.js"></script>-->
<script src="assets/vendor.js"></script>
<script src="assets/my-app.js"></script>
...
the console reports:
file changed helpers\highlight.js
helpers/highlight.js: line 4, col 19, 'Handlebars' is not defined.
I tried even (my-app\config\environment.js):
EmberENV: {
FEATURES: {
'ember-handlebars': true
The error message was the same. Please, could you help to properly add the helper method to my test app.
====================================== UPDATE
Fixed:
ember\my-app\bower.json
...
"qunit": "~1.17.1",
"ember-handlebars": "http://cloud.github.com/downloads/wycats/handlebars.js/handlebars-1.0.0.beta.6.js"
}
bower install
...
// var escaped = Handlebars.Utils.escapeExpression(value);
var escaped = Ember.Handlebars.Utils.escapeExpression(value);
...