summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/handlebars/compiler/compiler.js5
-rw-r--r--lib/handlebars/runtime.js9
2 files changed, 8 insertions, 6 deletions
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js
index b148bbb..e38f157 100644
--- a/lib/handlebars/compiler/compiler.js
+++ b/lib/handlebars/compiler/compiler.js
@@ -539,10 +539,7 @@ Handlebars.JavaScriptCompiler = function() {};
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;
+ source = "this.compiledVersion = '"+Handlebars.VERSION+"';\n"+source;
}
if (asObject) {
diff --git a/lib/handlebars/runtime.js b/lib/handlebars/runtime.js
index f29efe4..66b550f 100644
--- a/lib/handlebars/runtime.js
+++ b/lib/handlebars/runtime.js
@@ -20,12 +20,17 @@ Handlebars.VM = {
}
},
programWithDepth: Handlebars.VM.programWithDepth,
- noop: Handlebars.VM.noop
+ noop: Handlebars.VM.noop,
+ compiledVersion: null
};
return function(context, options) {
options = options || {};
- return templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data);
+ var result = templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data);
+ if (container.compiledVersion !== Handlebars.VERSION) {
+ throw "Template was compiled with "+(container.compiledVersion || 'unknown version')+", but runtime is "+Handlebars.VERSION;
+ }
+ return result;
};
},