Source

knockout-external-templates /

Filename Size Date modified Message
src
1.0 KB
703 B

knockout-external-templates

A super-simple external template loader for KnockoutJS.

Loads the template data from the server, rather than looking in <script> tags.

Usage:

Simplest: just include this file, and it will look for templates at:

/templates/<template-name>.html

If you want to change the settings:

require(['knockout/external-templates'], function(tmpl) {
  tmpl.location = 'http://example.com/__templates__/';
  tmpl.prefix = 'template_'
  tmpl.suffix = '.htm';

  tmpl.notFound = function(name, location) {
    return 'Oops. Could not find ' + name + ' at ' + location';
  };
});

.location may be a different server, subject to CORS.