Skip to content

Instantly share code, notes, and snippets.

@fgrehm

fgrehm/gist:4489503

Last active Nov 30, 2020
Embed
What would you like to do?
knockout.js + handlebars
class HandlebarsTemplateEngine extends ko.templateEngine
renderTemplateSource: (compiledTemplate, bindingContext, options) ->
data = bindingContext.$data
htmlResult = compiledTemplate(data)
ko.utils.parseHtmlFragment(htmlResult)
makeTemplateSource: (template, templateDocument) ->
throw "Could not find a template named: '#{template}'" unless JST[template]
JST[template]
# TODO: Figure out what this method is supposed to do
isTemplateRewritten: ->
true
ko.setTemplateEngine new HandlebarsTemplateEngine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment