Log deprecation notice for {{#isolate}}, {{#constant}}, preserve

This commit is contained in:
Avital Oliver
2014-02-27 11:38:42 -08:00
parent 208bbea9aa
commit 8efff3ebb7
3 changed files with 17 additions and 10 deletions

View File

@@ -675,6 +675,7 @@ Tinytest.add('spacebars - templates - no data context', function (test) {
Tinytest.add('spacebars - templates - isolate', function (test) {
var tmpl = Template.spacebars_template_test_isolate;
Meteor._suppress_log(1); // we print a deprecation notice
var div = renderToDiv(tmpl);
test.equal(canonicalizeHtml(div.innerHTML), 'hello');
@@ -684,6 +685,7 @@ Tinytest.add('spacebars - templates - isolate', function (test) {
Tinytest.add('spacebars - templates - constant', function (test) {
var tmpl = Template.spacebars_template_test_constant;
Meteor._suppress_log(1); // we print a deprecation notice
var div = renderToDiv(tmpl);
test.equal(canonicalizeHtml(div.innerHTML), 'hello');

View File

@@ -348,4 +348,6 @@ UI.Component.notifyParented = function () {
};
// past compat
UI.Component.preserve = function () {};
UI.Component.preserve = function () {
Meteor._debug("The 'preserve' method on templates is now unnecessary and deprecated.");
};

View File

@@ -12,20 +12,23 @@ var lookupComponentProp = function (comp, prop) {
};
// Component that's a no-op when used as a block helper like
// `{{#foo}}...{{/foo}}`.
var noOpComponent = Component.extend({
kind: 'NoOp',
render: function () {
return this.__content;
}
});
// `{{#foo}}...{{/foo}}`. Prints a warning that it is deprecated.
var noOpComponent = function (name) {
return Component.extend({
kind: 'NoOp',
render: function () {
Meteor._debug("{{#" + name + "}} is now unnecessary and deprecated.");
return this.__content;
}
});
};
// This map is searched first when you do something like `{{#foo}}` in
// a template.
var builtInComponents = {
// for past compat:
'constant': noOpComponent,
'isolate': noOpComponent
'constant': noOpComponent("constant"),
'isolate': noOpComponent("isolate")
};
_extend(UI.Component, {