UNPKG

twing

Version:

First-class Twig engine for Node.js

22 lines (21 loc) 1.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.executeNameNodeSynchronously = exports.executeNameNode = void 0; const traceable_method_1 = require("../../helpers/traceable-method"); const get_context_value_1 = require("../../helpers/get-context-value"); const context_1 = require("../../context"); const merge_iterables_1 = require("../../helpers/merge-iterables"); const executeNameNode = (node, { template, context, environment, strict }) => { const { name, isAlwaysDefined, shouldIgnoreStrictCheck, shouldTestExistence } = node.attributes; const traceableGetContextValue = (0, traceable_method_1.getTraceableMethod)(get_context_value_1.getContextValue, node, template.source); return traceableGetContextValue(environment.charset, template.name, strict, (0, context_1.createContext)((0, merge_iterables_1.mergeIterables)(environment.globals, context)), name, isAlwaysDefined, shouldIgnoreStrictCheck, shouldTestExistence); }; exports.executeNameNode = executeNameNode; const executeNameNodeSynchronously = (node, { template, context, environment, strict }) => { const { name, isAlwaysDefined, shouldIgnoreStrictCheck, shouldTestExistence } = node.attributes; const traceableGetContextValue = (0, traceable_method_1.getSynchronousTraceableMethod)(get_context_value_1.getContextValueSynchronously, node, template.source); return traceableGetContextValue(environment.charset, template.name, strict, // todo: this is needed for the for loop to work properly when the sequence is the context, but this should not be needed new Map(context.entries()), environment.globals, name, isAlwaysDefined, shouldIgnoreStrictCheck, shouldTestExistence); }; exports.executeNameNodeSynchronously = executeNameNodeSynchronously;