Last active
November 30, 2020 16:25
-
-
Save fgrehm/4489503 to your computer and use it in GitHub Desktop.
knockout.js + handlebars
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
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