summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/runtime.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/handlebars/runtime.js')
-rw-r--r--lib/handlebars/runtime.js23
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/handlebars/runtime.js b/lib/handlebars/runtime.js
index 2300439..e1b069e 100644
--- a/lib/handlebars/runtime.js
+++ b/lib/handlebars/runtime.js
@@ -90,7 +90,9 @@ export function template(templateSpec, env) {
invokePartial: invokePartialWrapper,
fn: function(i) {
- return templateSpec[i];
+ let ret = templateSpec[i];
+ ret.decorator = templateSpec[i + '_d'];
+ return ret;
},
programs: [],
@@ -142,7 +144,17 @@ export function template(templateSpec, env) {
}
}
- return '' + templateSpec.main(container, context, container.helpers, container.partials, data, blockParams, depths);
+ function main(context/*, options*/) {
+ return '' + templateSpec.main(container, context, container.helpers, container.partials, data, blockParams, depths);
+ }
+
+ if (templateSpec.main_d) {
+ // Note that we are ignoring the props value here as we apply things slightly differently
+ // when applying decorators to the root function.
+ main = templateSpec.main_d(main, {}, container, undefined, data, blockParams, depths);
+ }
+
+ return main(context, options);
}
ret.isTop = true;
@@ -190,6 +202,13 @@ export function wrapProgram(container, i, fn, data, declaredBlockParams, blockPa
blockParams && [options.blockParams].concat(blockParams),
currentDepths);
}
+
+ if (fn.decorator) {
+ let props = {};
+ prog = fn.decorator(prog, props, container, depths && depths[0], data, blockParams, depths);
+ Utils.extend(prog, props);
+ }
+
prog.program = i;
prog.depth = depths ? depths.length : 0;
prog.blockParams = declaredBlockParams || 0;