Expose the initial context via @root
This commit is contained in:
@@ -121,7 +121,7 @@ JavaScriptCompiler.prototype = {
|
||||
|
||||
var copies = "helpers = this.merge(helpers, " + namespace + ".helpers);";
|
||||
if (this.environment.usePartial) { copies = copies + " partials = this.merge(partials, " + namespace + ".partials);"; }
|
||||
if (this.options.data) { copies = copies + " data = data || {};"; }
|
||||
if (this.options.data) { copies = copies + " data = this.initData(depth0, data);"; }
|
||||
out.push(copies);
|
||||
} else {
|
||||
out.push('');
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user