From 9f2b2b5d18e2e6d97540ecedb0105d2e7bbeb228 Mon Sep 17 00:00:00 2001 From: Matthew Schinckel Date: Sun, 31 Mar 2013 16:17:30 +1030 Subject: [PATCH 1/2] Fixup to use proper ko name. --- lib/koExternalTemplateEngine-amd.js | 2 +- lib/koExternalTemplateEngine-amd.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/koExternalTemplateEngine-amd.js b/lib/koExternalTemplateEngine-amd.js index 643fb3e..efa4a70 100644 --- a/lib/koExternalTemplateEngine-amd.js +++ b/lib/koExternalTemplateEngine-amd.js @@ -7,7 +7,7 @@ // This is the AMD style module version of the KO External Template Engine // If you need the standard 'js lib' version, please go to https://github.com/ifandelse/Knockout.js-External-Template-Engine -define(['ko','jquery', 'infuser'], function(ko, jQuery, infuser){ +define(['knockout','jquery', 'infuser'], function(ko, jQuery, infuser){ var ExternalTemplateSource = function(templateId, options) { var self = this, origAfterRender; diff --git a/lib/koExternalTemplateEngine-amd.min.js b/lib/koExternalTemplateEngine-amd.min.js index 8688a16..3b1cd61 100644 --- a/lib/koExternalTemplateEngine-amd.min.js +++ b/lib/koExternalTemplateEngine-amd.min.js @@ -1 +1 @@ -define(["ko","jquery","infuser"],function(ko,jQuery,infuser){var ExternalTemplateSource=function(templateId,options){var self=this,origAfterRender;self.templateId=templateId,self.loaded=!1,self.template=ko.observable(infuser.defaults.useLoadingTemplate?infuser.defaults.loadingTemplate.content:undefined),self.template.data={},self.options=ko.utils.extend({},options),self.options.templateId=templateId,self.options&&self.options.afterRender&&(origAfterRender=self.options.afterRender,self.options.afterRender=function(){self.loaded&&origAfterRender.apply(self.options,arguments)})};ko.utils.extend(ExternalTemplateSource.prototype,{data:function(key,value){if(arguments.length===1)return key==="precompiled"&&this.template(),this.template.data[key];this.template.data[key]=value},text:function(value){this.loaded||this.getTemplate();if(arguments.length===0)return this.template();this.template(arguments[0])},getTemplate:function(){var self=this;infuser.get(self.options,function(tmpl){self.data("precompiled",null),self.template(tmpl),self.loaded=!0})}});var KoExternalTemplateEngine=function(koEngineType){var engine=koEngineType?new koEngineType:new ko.nativeTemplateEngine;return engine.templates={},engine.makeTemplateSource=function(template,bindingContext,options){if(typeof template=="string"){var elem=document.getElementById(template);return elem?new ko.templateSources.domElement(elem):(engine.templates[template]||(engine.templates[template]=new ExternalTemplateSource(template,options)),engine.templates[template])}if(template.nodeType==1||template.nodeType==8)return new ko.templateSources.anonymousTemplate(template)},engine.renderTemplate=function(template,bindingContext,options){var templateSource=engine.makeTemplateSource(template,bindingContext,options);return engine.renderTemplateSource(templateSource,bindingContext,options)},engine};ko.KoExternalTemplateEngine=KoExternalTemplateEngine,jQuery.tmpl&&jQuery.tmpl.tag.tmpl.open.toString().indexOf("__")>=0?ko.setTemplateEngine(new KoExternalTemplateEngine(ko.jqueryTmplTemplateEngine)):ko.setTemplateEngine(new KoExternalTemplateEngine)}) \ No newline at end of file +define(["knockout","jquery","infuser"],function(ko,jQuery,infuser){var ExternalTemplateSource=function(templateId,options){var self=this,origAfterRender;self.templateId=templateId,self.loaded=!1,self.template=ko.observable(infuser.defaults.useLoadingTemplate?infuser.defaults.loadingTemplate.content:undefined),self.template.data={},self.options=ko.utils.extend({},options),self.options.templateId=templateId,self.options&&self.options.afterRender&&(origAfterRender=self.options.afterRender,self.options.afterRender=function(){self.loaded&&origAfterRender.apply(self.options,arguments)})};ko.utils.extend(ExternalTemplateSource.prototype,{data:function(key,value){if(arguments.length===1)return key==="precompiled"&&this.template(),this.template.data[key];this.template.data[key]=value},text:function(value){this.loaded||this.getTemplate();if(arguments.length===0)return this.template();this.template(arguments[0])},getTemplate:function(){var self=this;infuser.get(self.options,function(tmpl){self.data("precompiled",null),self.template(tmpl),self.loaded=!0})}});var KoExternalTemplateEngine=function(koEngineType){var engine=koEngineType?new koEngineType:new ko.nativeTemplateEngine;return engine.templates={},engine.makeTemplateSource=function(template,bindingContext,options){if(typeof template=="string"){var elem=document.getElementById(template);return elem?new ko.templateSources.domElement(elem):(engine.templates[template]||(engine.templates[template]=new ExternalTemplateSource(template,options)),engine.templates[template])}if(template.nodeType==1||template.nodeType==8)return new ko.templateSources.anonymousTemplate(template)},engine.renderTemplate=function(template,bindingContext,options){var templateSource=engine.makeTemplateSource(template,bindingContext,options);return engine.renderTemplateSource(templateSource,bindingContext,options)},engine};ko.KoExternalTemplateEngine=KoExternalTemplateEngine,jQuery.tmpl&&jQuery.tmpl.tag.tmpl.open.toString().indexOf("__")>=0?ko.setTemplateEngine(new KoExternalTemplateEngine(ko.jqueryTmplTemplateEngine)):ko.setTemplateEngine(new KoExternalTemplateEngine)}) \ No newline at end of file From 9446010156c28fc34961ff0db9c1a5532beaa597 Mon Sep 17 00:00:00 2001 From: Matthew Schinckel Date: Sun, 31 Mar 2013 16:26:26 +1030 Subject: [PATCH 2/2] The canonical name for knockout should not be ko. --- src/koExternalTemplateEngine-amd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/koExternalTemplateEngine-amd.js b/src/koExternalTemplateEngine-amd.js index 1c39673..49a06a1 100644 --- a/src/koExternalTemplateEngine-amd.js +++ b/src/koExternalTemplateEngine-amd.js @@ -2,7 +2,7 @@ // This is the AMD style module version of the KO External Template Engine // If you need the standard 'js lib' version, please go to https://github.com/ifandelse/Knockout.js-External-Template-Engine -define(['ko','jquery', 'infuser'], function(ko, jQuery, infuser){ +define(['knockout','jquery', 'infuser'], function(ko, jQuery, infuser){ //import("ExternalTemplateSource.js"); //import("TemplateEngine.js");