Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Blaze._getTemplate to allow resolving into Blaze Components #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions dynamic_template.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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({
Expand Down