Add child accessor API
This commit is contained in:
@@ -453,10 +453,17 @@ export function compile(input, options, env) {
|
||||
}
|
||||
|
||||
// Template is only compiled on first use and cached after that point.
|
||||
return function(context, options) {
|
||||
var ret = function(context, options) {
|
||||
if (!compiled) {
|
||||
compiled = compileInput();
|
||||
}
|
||||
return compiled.call(this, context, options);
|
||||
};
|
||||
ret.child = function(i) {
|
||||
if (!compiled) {
|
||||
compiled = compileInput();
|
||||
}
|
||||
return compiled.child(i);
|
||||
};
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ export function template(templateSpec, env) {
|
||||
compilerInfo: templateSpec.compiler
|
||||
};
|
||||
|
||||
return function(context, options) {
|
||||
var ret = function(context, options) {
|
||||
options = options || {};
|
||||
var namespace = options.partial ? options : env,
|
||||
helpers,
|
||||
@@ -119,6 +119,11 @@ export function template(templateSpec, env) {
|
||||
}
|
||||
return templateSpec.main.call(container, context, helpers, partials, data);
|
||||
};
|
||||
|
||||
ret.child = function(i) {
|
||||
return container.programWithDepth(i);
|
||||
};
|
||||
return ret;
|
||||
}
|
||||
|
||||
export function programWithDepth(i, data /*, $depth */) {
|
||||
|
||||
Reference in New Issue
Block a user