Add child accessor API

This commit is contained in:
kpdecker
2014-01-19 21:18:21 -06:00
parent d00d8b6776
commit c72a8d5e84
2 changed files with 14 additions and 2 deletions
+8 -1
View File
@@ -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;
}
+6 -1
View File
@@ -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 */) {