summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/runtime.js
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2014-01-15 09:41:53 -0600
committerkpdecker <kpdecker@gmail.com>2014-01-15 09:41:53 -0600
commitf650b0d69ec70f82fc58022a530b95b0e4371f1d (patch)
tree867668c9b560cd74247f3db82331130228d45cf4 /lib/handlebars/runtime.js
parentd841ad59628373488d880b6a05075687f8120b4c (diff)
downloadhandlebars.js-f650b0d69ec70f82fc58022a530b95b0e4371f1d.zip
handlebars.js-f650b0d69ec70f82fc58022a530b95b0e4371f1d.tar.gz
handlebars.js-f650b0d69ec70f82fc58022a530b95b0e4371f1d.tar.bz2
Expose the initial context via @root
Diffstat (limited to 'lib/handlebars/runtime.js')
-rw-r--r--lib/handlebars/runtime.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/handlebars/runtime.js b/lib/handlebars/runtime.js
index 5ae8d8a..d31e5f4 100644
--- a/lib/handlebars/runtime.js
+++ b/lib/handlebars/runtime.js
@@ -1,6 +1,6 @@
module Utils from "./utils";
import Exception from "./exception";
-import { COMPILER_REVISION, REVISION_CHANGES } from "./base";
+import { COMPILER_REVISION, REVISION_CHANGES, createFrame } from "./base";
export function checkRevision(compilerInfo) {
var compilerRevision = compilerInfo && compilerInfo[0] || 1,
@@ -56,6 +56,13 @@ export function template(templateSpec, env) {
}
return programWrapper;
},
+ initData: function(context, data) {
+ data = data ? createFrame(data) : {};
+ if (!('root' in data)) {
+ data.root = context;
+ }
+ return data;
+ },
merge: function(param, common) {
var ret = param || common;