Check version when evaluating templates.

This makes sure that we throw an error when a template was precompiled
with a version of Handlebars that doesn't match the evaluating version.
This commit is contained in:
Peter Wagenet
2013-01-29 11:43:43 -08:00
parent a3376e24b1
commit d7758fe1a9
2 changed files with 14 additions and 0 deletions
+7
View File
@@ -1380,6 +1380,13 @@ Handlebars.JavaScriptCompiler = function() {};
// Perform a second pass over the output to merge content when possible
var source = this.mergeSource();
if (!this.isChild) {
source = "if (Handlebars.VERSION !== '"+Handlebars.VERSION+"') {\n"+
"throw 'Template was compiled with "+Handlebars.VERSION+", but runtime is '+Handlebars.VERSION;\n"+
"}\n"+
source;
}
if (asObject) {
params.push(source);
+7
View File
@@ -538,6 +538,13 @@ Handlebars.JavaScriptCompiler = function() {};
// Perform a second pass over the output to merge content when possible
var source = this.mergeSource();
if (!this.isChild) {
source = "if (Handlebars.VERSION !== '"+Handlebars.VERSION+"') {\n"+
"throw 'Template was compiled with "+Handlebars.VERSION+", but runtime is '+Handlebars.VERSION;\n"+
"}\n"+
source;
}
if (asObject) {
params.push(source);