Skip to content

Commit

Permalink
Merge pull request #370 from meteor/fix/remove-old-tests
Browse files Browse the repository at this point in the history
Remove tests for removed API in spacebars, fix #369
  • Loading branch information
denihs authored Apr 20, 2022
2 parents 48853c3 + c508e17 commit a2123a4
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 27 deletions.
4 changes: 3 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## v2.6.1, 2022-April-xx
## v2.6.1, 2022-April-XX

* [#370](https://github.com/meteor/blaze/pull/370) `[email protected]`, returned the `Template.__define__` with warning message
* [#366](https://github.com/meteor/blaze/pull/366) Prevent firing callbacks until members are destroyed
* fix destroying child templates when parent is destroyed; prevents memory leak and DOMRange "not attached" error

Expand Down
2 changes: 1 addition & 1 deletion packages/blaze/builtins.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ Blaze._TemplateWith = function (arg, contentFunc) {
// parent Views in the current template. However, when there's an argument
// (`{{> Template.contentBlock arg}}`), the argument needs to be evaluated
// in the original scope. There's no good order to nest
// Blaze._InOuterTemplateScope and Spacebars.TemplateWith to achieve this,
// Blaze._InOuterTemplateScope and Blaze._TemplateWith to achieve this,
// so we wrap argFunc to run it in the "original parentView" of the
// Blaze._InOuterTemplateScope.
//
Expand Down
46 changes: 23 additions & 23 deletions packages/spacebars-tests/old_templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Template.__define__("old_spacebars_template_test_span_this", (function() {

Template.__define__("old_spacebars_template_test_content", (function() {
var view = this;
return Blaze.InOuterTemplateScope(view, function() {
return Blaze._InOuterTemplateScope(view, function() {
return Spacebars.include(function() {
return Spacebars.call(view.templateContentBlock);
});
Expand All @@ -47,7 +47,7 @@ Template.__define__("old_spacebars_template_test_content", (function() {

Template.__define__("old_spacebars_template_test_elsecontent", (function() {
var view = this;
return Blaze.InOuterTemplateScope(view, function() {
return Blaze._InOuterTemplateScope(view, function() {
return Spacebars.include(function() {
return Spacebars.call(view.templateElseBlock);
});
Expand All @@ -59,13 +59,13 @@ Template.__define__("old_spacebars_template_test_iftemplate", (function() {
return Blaze.If(function() {
return Spacebars.call(view.lookup("condition"));
}, function() {
return [ "\n ", Blaze.InOuterTemplateScope(view, function() {
return [ "\n ", Blaze._InOuterTemplateScope(view, function() {
return Spacebars.include(function() {
return Spacebars.call(view.templateContentBlock);
});
}), "\n " ];
}, function() {
return [ "\n ", Blaze.InOuterTemplateScope(view, function() {
return [ "\n ", Blaze._InOuterTemplateScope(view, function() {
return Spacebars.include(function() {
return Spacebars.call(view.templateElseBlock);
});
Expand Down Expand Up @@ -125,7 +125,7 @@ Template.__define__("old_spacebars_template_test_triple2", (function() {

Template.__define__("old_spacebars_template_test_inclusion_args", (function() {
var view = this;
return Spacebars.TemplateWith(function() {
return Blaze._TemplateWith(function() {
return Spacebars.call(view.lookup("bar"));
}, function() {
return Spacebars.include(view.lookupTemplate("foo"));
Expand All @@ -134,7 +134,7 @@ Template.__define__("old_spacebars_template_test_inclusion_args", (function() {

Template.__define__("old_spacebars_template_test_inclusion_args2", (function() {
var view = this;
return Spacebars.TemplateWith(function() {
return Blaze._TemplateWith(function() {
return Spacebars.dataMustache(view.lookup("bar"), Spacebars.kw({
q: view.lookup("baz")
}));
Expand All @@ -145,7 +145,7 @@ Template.__define__("old_spacebars_template_test_inclusion_args2", (function() {

Template.__define__("old_spacebars_template_test_inclusion_dotted_args", (function() {
var view = this;
return Spacebars.TemplateWith(function() {
return Blaze._TemplateWith(function() {
return Spacebars.call(Spacebars.dot(view.lookup("bar"), "baz"));
}, function() {
return Spacebars.include(view.lookupTemplate("foo"));
Expand All @@ -154,7 +154,7 @@ Template.__define__("old_spacebars_template_test_inclusion_dotted_args", (functi

Template.__define__("old_spacebars_template_test_inclusion_slashed_args", (function() {
var view = this;
return Spacebars.TemplateWith(function() {
return Blaze._TemplateWith(function() {
return Spacebars.call(Spacebars.dot(view.lookup("bar"), "baz"));
}, function() {
return Spacebars.include(view.lookupTemplate("foo"));
Expand All @@ -172,7 +172,7 @@ Template.__define__("old_spacebars_template_test_block_helper", (function() {

Template.__define__("old_spacebars_template_test_block_helper_function_one_string_arg", (function() {
var view = this;
return Spacebars.TemplateWith(function() {
return Blaze._TemplateWith(function() {
return "bar";
}, function() {
return Spacebars.include(view.lookupTemplate("foo"), function() {
Expand All @@ -183,7 +183,7 @@ Template.__define__("old_spacebars_template_test_block_helper_function_one_strin

Template.__define__("old_spacebars_template_test_block_helper_function_one_helper_arg", (function() {
var view = this;
return Spacebars.TemplateWith(function() {
return Blaze._TemplateWith(function() {
return Spacebars.call(view.lookup("bar"));
}, function() {
return Spacebars.include(view.lookupTemplate("foo"), function() {
Expand Down Expand Up @@ -212,7 +212,7 @@ Template.__define__("old_spacebars_template_test_block_helper_component_three_he

Template.__define__("old_spacebars_template_test_block_helper_dotted_arg", (function() {
var view = this;
return Spacebars.TemplateWith(function() {
return Blaze._TemplateWith(function() {
return Spacebars.dataMustache(Spacebars.dot(view.lookup("bar"), "baz"), view.lookup("qux"));
}, function() {
return Spacebars.include(view.lookupTemplate("foo"), function() {
Expand All @@ -223,7 +223,7 @@ Template.__define__("old_spacebars_template_test_block_helper_dotted_arg", (func

Template.__define__("old_spacebars_template_test_nested_content", (function() {
var view = this;
return Spacebars.TemplateWith(function() {
return Blaze._TemplateWith(function() {
return {
condition: Spacebars.call(view.lookup("flag"))
};
Expand All @@ -238,19 +238,19 @@ Template.__define__("old_spacebars_template_test_nested_content", (function() {

Template.__define__("old_spacebars_template_test_iftemplate2", (function() {
var view = this;
return Spacebars.TemplateWith(function() {
return Blaze._TemplateWith(function() {
return {
condition: Spacebars.call(view.lookup("flag"))
};
}, function() {
return Spacebars.include(view.lookupTemplate("old_spacebars_template_test_iftemplate"), function() {
return [ "\n ", Blaze.InOuterTemplateScope(view, function() {
return [ "\n ", Blaze._InOuterTemplateScope(view, function() {
return Spacebars.include(function() {
return Spacebars.call(view.templateContentBlock);
});
}), "\n " ];
}, function() {
return [ "\n ", Blaze.InOuterTemplateScope(view, function() {
return [ "\n ", Blaze._InOuterTemplateScope(view, function() {
return Spacebars.include(function() {
return Spacebars.call(view.templateElseBlock);
});
Expand All @@ -261,7 +261,7 @@ Template.__define__("old_spacebars_template_test_iftemplate2", (function() {

Template.__define__("old_spacebars_template_test_nested_content2", (function() {
var view = this;
return Spacebars.TemplateWith(function() {
return Blaze._TemplateWith(function() {
return {
flag: Spacebars.call(view.lookup("x"))
};
Expand Down Expand Up @@ -333,7 +333,7 @@ Template.__define__("old_spacebars_template_test_dots", (function() {
return [ "\n C\n ", Blaze.Each(function() {
return Spacebars.call(view.lookup("items"));
}, function() {
return [ "\n D\n \n ", Spacebars.include(view.lookupTemplate("old_spacebars_template_test_dots_subtemplate")), "\n ", Spacebars.TemplateWith(function() {
return [ "\n D\n \n ", Spacebars.include(view.lookupTemplate("old_spacebars_template_test_dots_subtemplate")), "\n ", Blaze._TemplateWith(function() {
return Spacebars.call(view.lookup(".."));
}, function() {
return Spacebars.include(view.lookupTemplate("old_spacebars_template_test_dots_subtemplate"));
Expand Down Expand Up @@ -755,7 +755,7 @@ Template.__define__("old_spacebars_template_test_markdown_block_helpers", (funct

Template.__define__("old_spacebars_template_test_just_content", (function() {
var view = this;
return Blaze.InOuterTemplateScope(view, function() {
return Blaze._InOuterTemplateScope(view, function() {
return Spacebars.include(function() {
return Spacebars.call(view.templateContentBlock);
});
Expand Down Expand Up @@ -882,7 +882,7 @@ Template.__define__("old_spacebars_template_test_content_context", (function() {
return [ "\n ", Spacebars.With(function() {
return Spacebars.call(view.lookup("bar"));
}, function() {
return [ "\n ", Spacebars.TemplateWith(function() {
return [ "\n ", Blaze._TemplateWith(function() {
return {
condition: Spacebars.call(view.lookup("cond"))
};
Expand Down Expand Up @@ -1184,7 +1184,7 @@ Template.__define__("old_spacebars_test_falsy_with", (function() {

Template.__define__("old_spacebars_test_helpers_dont_leak", (function() {
var view = this;
return Spacebars.TemplateWith(function() {
return Blaze._TemplateWith(function() {
return {
foo: Spacebars.call("correct")
};
Expand Down Expand Up @@ -1480,7 +1480,7 @@ Template.__define__("old_spacebars_test_template_created_rendered_destroyed_each
return Blaze.Each(function() {
return Spacebars.call(view.lookup("items"));
}, function() {
return [ "\n ", HTML.DIV(Spacebars.TemplateWith(function() {
return [ "\n ", HTML.DIV(Blaze._TemplateWith(function() {
return Spacebars.call(view.lookup("_id"));
}, function() {
return Spacebars.include(view.lookupTemplate("old_spacebars_test_template_created_rendered_destroyed_each_sub"));
Expand Down Expand Up @@ -1687,8 +1687,8 @@ Template.__define__("old_spacebars_test_contentBlock_arg_inner", (function() {
}, function() {
return [ "\n ", Blaze.View(function() {
return Spacebars.mustache(Spacebars.dot(view.lookup("."), "foo"));
}), " ", Blaze.InOuterTemplateScope(view, function() {
return Spacebars.TemplateWith(function() {
}), " ", Blaze._InOuterTemplateScope(view, function() {
return Blaze._TemplateWith(function() {
return Spacebars.call(view.lookup("."));
}, function() {
return Spacebars.include(function() {
Expand Down
4 changes: 2 additions & 2 deletions packages/templating-runtime/package.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package.describe({
name: 'templating-runtime',
summary: "Runtime for compiled .html files",
version: '1.6.0',
version: '1.6.1',
git: 'https://github.com/meteor/blaze.git',
documentation: null
});
Expand All @@ -28,7 +28,7 @@ Package.onUse(function (api) {
'[email protected]'
]);
api.imply([
'meteor@1.2.17', // TODO update
'meteor@1.10.0',
'[email protected]',
'[email protected]'
], 'client');
Expand Down
21 changes: 21 additions & 0 deletions packages/templating-runtime/templating.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@ Template.__checkName = function (name) {
}
};

var shownWarning = false;

// XXX COMPAT WITH 0.8.3
Template.__define__ = function (name, renderFunc) {
Template.__checkName(name);
Template[name] = new Template("Template." + name, renderFunc);
// Exempt packages built pre-0.9.0 from warnings about using old
// helper syntax, because we can. It's not very useful to get a
// warning about someone else's code (like a package on Atmosphere),
// and this should at least put a bit of a dent in number of warnings
// that come from packages that haven't been updated lately.
Template[name]._NOWARN_OLDSTYLE_HELPERS = true;

// Now we want to show at least one warning so that people get serious about
// updating away from this method.
if (!shownWarning) {
shownWarning = true;
console.warn("You app is using old Template definition that is scheduled to be removed with Blaze 3.0, please check your app and packages for use of: Template.__define__");
}
};

// Define a template `Template.body` that renders its
// `contentRenderFuncs`. `<body>` tags (of which there may be
// multiple) will have their contents added to it.
Expand Down

0 comments on commit a2123a4

Please sign in to comment.