ember.js - How can I include given Handlebars helpers in Ember -


on github, many handlebars helpers presented. can find them here.

i'd use them, have no idea, how include them. code looking it's javascript (files ending .js ...), words 'import','export','default' confusing me.

as understand (guess), have include if-condition.js @ first. later, other (included) files refer file.

but when this, console throws error:

uncaught syntaxerror: unexpected reserved word .

has idea, how these codes working?

import , export keywords upcoming module syntax in next version of javascript. can use them today using transpiler convert normal es5 syntax.

however, if you're using few helpers, it's easy 'transpile' them hand. instead of exporting function, pass ember.hanldebars.registerboundhelper call. here's if-condition helper:

ember.handlebars.registerboundhelper('if-condition', function() {     var args = [].slice.call(arguments);     var options = args.pop();     var context = (options.contexts && options.contexts[0]) || this;      if (!options.conditional) {         throw new error("a conditional callback must specified when using if-condition helper");     }      // gather bound property names pass in order observe them     var properties = options.types.reduce(function(results, type, index) {         if (type === 'id') {             results.push(args[index]);         }         return results;     }, []);      // resolve actual values params pass conditional callback     var normalizer = function() {         return ember.handlebars.resolveparams(context, args, options);     };      // makes helper bound helper     // note: 'content' path used multiple properties can bound using `childproperties` argument,     // means can used controller proxies values 'content' property     return ember.handlebars.bind.call(context, 'content', options, true, options.conditional, normalizer, properties); }); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -