MCPcopy
hub / github.com/handlebars-lang/handlebars.js / wrapProgram

Function wrapProgram

lib/handlebars/runtime.js:308–344  ·  view source on GitHub ↗
(
  container,
  i,
  fn,
  data,
  declaredBlockParams,
  blockParams,
  depths
)

Source from the content-addressed store, hash-verified

306}
307
308export function wrapProgram(
309 container,
310 i,
311 fn,
312 data,
313 declaredBlockParams,
314 blockParams,
315 depths
316) {
317 function prog(context, options = {}) {
318 let currentDepths = depths;
319 if (
320 depths &&
321 context != depths[0] &&
322 !(context === container.nullContext && depths[0] === null)
323 ) {
324 currentDepths = [context].concat(depths);
325 }
326
327 return fn(
328 container,
329 context,
330 container.helpers,
331 container.partials,
332 options.data || data,
333 blockParams && [options.blockParams].concat(blockParams),
334 currentDepths
335 );
336 }
337
338 prog = executeDecorators(fn, prog, container, depths, data, blockParams);
339
340 prog.program = i;
341 prog.depth = depths ? depths.length : 0;
342 prog.blockParams = declaredBlockParams || 0;
343 return prog;
344}
345
346/**
347 * This is currently part of the official API, therefore implementation details should not be changed.

Callers 1

templateFunction · 0.85

Calls 1

executeDecoratorsFunction · 0.85

Tested by

no test coverage detected