Skip to content

Instantly share code, notes, and snippets.

@aeinbu
Created September 29, 2015 18:39
Show Gist options
  • Save aeinbu/03b82aa2a45c1f00dbb7 to your computer and use it in GitHub Desktop.
Save aeinbu/03b82aa2a45c1f00dbb7 to your computer and use it in GitHub Desktop.
import ko from 'knockout';
import $ from 'jquery';
var templateFromUrlLoader = {
loadTemplate(name, templateConfig, callback) {
if (templateConfig.fromUrl) {
var fullUrl = templateConfig.fromUrl;
$.get(fullUrl, markupString => {
ko.components.defaultLoader.loadTemplate(name, markupString, callback);
});
} else {
// Unrecognized config format. Let another loader handle it.
callback(null);
}
}
};
// Register it
ko.components.loaders.unshift(templateFromUrlLoader);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment