diff --git a/dynamic_template.js b/dynamic_template.js index dd39d1f..9cbbaf4 100644 --- a/dynamic_template.js +++ b/dynamic_template.js @@ -121,7 +121,7 @@ DynamicTemplate.prototype.create = function (options) { this.isCreated = true; this.isDestroyed = false; - var templateVar = ReactiveVar(null); + var templateVar = ReactiveVar(null, function (a, b) {return a === b}); var view = Blaze.View('DynamicTemplate', function () { var thisView = this; @@ -218,12 +218,29 @@ DynamicTemplate.prototype.renderView = function (template) { // is it a template name like "MyTemplate"? if (typeof template === 'string') { - tmpl = Template[template]; + if (Blaze._getTemplate) { + tmpl = Blaze._getTemplate(template, function () { + return self; + }); + } + else { + // Backwards compatibility for Meteor < 1.2. + tmpl = Template[template]; + } - if (!tmpl) + if (!tmpl) { // as a fallback double check the user didn't actually define // a camelCase version of the template. - tmpl = Template[camelCase(template)]; + if (Blaze._getTemplate) { + tmpl = Blaze._getTemplate(camelCase(template), function () { + return self; + }); + } + else { + // Backwards compatibility for Meteor < 1.2. + tmpl = Template[camelCase(template)]; + } + } if (!tmpl) { tmpl = Blaze.With({