Skip to content

Instantly share code, notes, and snippets.

@LukeChannings
LukeChannings / handlebars-select-helper.js
Last active August 5, 2024 20:15
A select helper for handlebars
Handlebars.registerHelper("select", function(value, options) {
return options.fn(this)
.split('\n')
.map(function(v) {
var t = 'value="' + value + '"'
return ! RegExp(t).test(v) ? v : v.replace(t, t + ' selected="selected"')
})
.join('\n')
})