|
6 | 6 | LAST_COMPATIBLE_COMPILER_REVISION,
|
7 | 7 | REVISION_CHANGES
|
8 | 8 | } from './base';
|
9 |
| -import { moveHelperToHooks } from './helpers'; |
10 |
| -import { wrapHelper } from './internal/wrapHelper'; |
| 9 | +import { mergeHelpers, moveHelperToHooks } from './helpers'; |
11 | 10 | import {
|
12 | 11 | createProtoAccessControl,
|
13 | 12 | resultIsAllowed
|
@@ -240,10 +239,7 @@ export function template(templateSpec, env) {
|
240 | 239 |
|
241 | 240 | ret._setup = function(options) {
|
242 | 241 | if (!options.partial) {
|
243 |
| - let mergedHelpers = {}; |
244 |
| - addHelpers(mergedHelpers, env.helpers, container); |
245 |
| - addHelpers(mergedHelpers, options.helpers, container); |
246 |
| - container.helpers = mergedHelpers; |
| 242 | + container.helpers = mergeHelpers(env, options, container); |
247 | 243 |
|
248 | 244 | if (templateSpec.usePartial) {
|
249 | 245 | // Use mergeIfNeeded here to prevent compiling global partials multiple times
|
@@ -421,19 +417,3 @@ function executeDecorators(fn, prog, container, depths, data, blockParams) {
|
421 | 417 | }
|
422 | 418 | return prog;
|
423 | 419 | }
|
424 |
| - |
425 |
| -function addHelpers(mergedHelpers, helpers, container) { |
426 |
| - if (!helpers) return; |
427 |
| - Object.keys(helpers).forEach(helperName => { |
428 |
| - let helper = helpers[helperName]; |
429 |
| - mergedHelpers[helperName] = passLookupPropertyOption(helper, container); |
430 |
| - }); |
431 |
| -} |
432 |
| - |
433 |
| -function passLookupPropertyOption(helper, container) { |
434 |
| - const lookupProperty = container.lookupProperty; |
435 |
| - return wrapHelper(helper, options => { |
436 |
| - options.lookupProperty = lookupProperty; |
437 |
| - return options; |
438 |
| - }); |
439 |
| -} |
0 commit comments