So I'm wanting to replace the Knockout templating engine with doT for enhanced performance for my large-scale single-page app. I've been able to get doT.js working with knockout as the templating engine, but i'm having a big issue.
I'm used to using Knockout's event
bindings to keep me from having to attach event handlers in my ViewModels. But doT.js doesn't seem to provide this option. I think the primary reason for this is that doT.js just compiles a string of html.
What would be the best way to being able to define events in my views and still use doT.js? Has this been done before?
My thought is that I would have to define my events in a data-
attribute and once doT.js is done compiling, throw that html string into a detached DOM element. Then I would have to do something like a .querySelectorAll
to find the data-
event attributes and attach those to the parent element.
Does anyone have any better thoughts on this?
JSFiddle Example
Here's an example of Knockout.js and doT.js working together (pulled from this example):