Knockstrap provides implementation of Knockout-compatible stringTemplateEngine, which can use strings as html templates.
For developers, constructor of engine available via ko.stringTemplateEngine.
Also it contains instance property, so it isn't necessary to create your own.
It can be used everywhere, where Knockout's nativeTemplateEngine is acceptable.
Template engine contains storage of templates, which is shared between all instances.
stringTemplateEngine contains:
addTemplate(name, template)
name
Type: string
Name of new template. If template already exists - it will be overwritten.
template
Type: string
Body of template. May contain any html.
removeTemplate(name)
name
Type: string
Name of template for deleting. If template doesn't exist - nothing happens.
getTemplate(name)
name
Type: string
Name of template.
isTemplateExist(name)
name
Type: string
Name of template.
instance
String template engine:
Native template engine:
<p>String template engine:</p>
<p data-bind="template: { name: 'demo', templateEngine: ko.stringTemplateEngine.instance }"></p>
<p>Native template engine:</p>
<p data-bind="template: { name: 'demo' }"></p>
<script id="demo" type="text/html">
<span>It's a <strong>native template engine</strong>!</span>
</script>
var ste = ko.stringTemplateEngine.instance;
ste.addTemplate('demo', '<span>It\'s a <strong>string template engine</strong>!</span>');