Skip to content

Instantly share code, notes, and snippets.

@digitalplaywright
Created April 29, 2014 18:48
Show Gist options
  • Save digitalplaywright/11408682 to your computer and use it in GitHub Desktop.
Save digitalplaywright/11408682 to your computer and use it in GitHub Desktop.
Handlebars.registerHelper("ifData", function(property, fn)
{
var context = (fn.contexts && fn.contexts[0]) || this;
var args = [property];
var canAction = function(can_args)
{
alert('I was called for '+can_args[0].get('id'));
return true;
};
// Resolve actual values for all params to pass to the conditional callback
var normalizer = function() {
return Ember.Handlebars.resolveParams(context, args, fn);
};
return Ember.Handlebars.bind.call(context, 'content', fn, true, canAction, normalizer, args);
});
{{#ifData model }}
<h1> Showme </h1>
{{/ifData}}
@digitalplaywright
Copy link
Author

ifData is not reevaluated when model is modified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment