diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/handlebars/runtime.js | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/handlebars/runtime.js b/lib/handlebars/runtime.js index d41b42a..bc12fc9 100644 --- a/lib/handlebars/runtime.js +++ b/lib/handlebars/runtime.js @@ -135,7 +135,11 @@ export function template(templateSpec, env) { let depths, blockParams = templateSpec.useBlockParams ? [] : undefined; if (templateSpec.useDepths) { - depths = options.depths ? [context].concat(options.depths) : [context]; + if (options.depths) { + depths = context !== options.depths[0] ? [context].concat(depths) : options.depths; + } else { + depths = [context]; + } } return templateSpec.main.call(container, context, container.helpers, container.partials, data, blockParams, depths); @@ -170,12 +174,17 @@ export function template(templateSpec, env) { export function wrapProgram(container, i, fn, data, declaredBlockParams, blockParams, depths) { function prog(context, options = {}) { + let currentDepths = depths; + if (depths && context !== depths[0]) { + currentDepths = [context].concat(depths); + } + return fn.call(container, context, container.helpers, container.partials, options.data || data, blockParams && [options.blockParams].concat(blockParams), - depths && [context].concat(depths)); + currentDepths); } prog.program = i; prog.depth = depths ? depths.length : 0; |