Created
February 6, 2012 22:43
-
-
Save danharper/1755604 to your computer and use it in GitHub Desktop.
Handlebars Conditional Helper with Arguments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Handlebars.registerHelper('if_task_state', function(options) { | |
var states = options.hash.is.split(',') | |
, r = false | |
; | |
_.each(states, function(state) { | |
if (state == this.model.state) | |
r = true; | |
}, this); | |
if (r) | |
return options.fn(this); | |
return options.inverse(this); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{#if_task_state is="Pending"}} | |
<p>Task is pending.</p> | |
{{else}} | |
<p>Task is not pending.</p> | |
{{/if_task_state}} | |
{{#if_task_state is="Completed,Closed"}} | |
<p>Task is completed <em>or</em> closed.</p> | |
{{/if_task_state}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment