I am trying to construct a Handlebars helper as below
export function ifBlankHyphen(value){
var template = "{{#if value}}{{value}}{{else}}--";
return new Ember.Handlebars.SafeString(template);
});
export default Ember.Handlebars.makeBoundHelper(ifBlankHyphen);
first of all I know I can do it the normal way that is in handlebars directly by using the if helper. But I was just seeing what all I could use a custom helper and coded the above part but to my surprise the output of
{{ifBlankHyphen "xyz"}}
came out to be in the handlebars as below
{{#if value}}{{value}}{{else}}--
so just want to confirm that in Custom helpers how can I use other helpers and compile it properly that it outputs proper template.
I tried to use "{{{" also but it was of no use. Is it possible to use Ember.Handlebars.compile here and get the template rendered properly in this case.
Aucun commentaire:
Enregistrer un commentaire