Skip to content

Instantly share code, notes, and snippets.

@Rockncoder
Created October 25, 2013 10:49
Show Gist options
  • Save Rockncoder/7152822 to your computer and use it in GitHub Desktop.
Save Rockncoder/7152822 to your computer and use it in GitHub Desktop.
Generating the attributes of an option element.
// Render an option tag's value and selected attributes
hbs.registerHelper("option", function (current, field) {
current = hbs.Utils.escapeExpression(current);
field = hbs.Utils.escapeExpression(field);
var results = 'value="' + current + '" ' + (field === current ? 'selected="selected"' : "");
return new hbs.SafeString(results);
});
@Rockncoder
Copy link
Author

A quick and dirty way to generate the attributes of an option element on the server-side with handlerbars.js.

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