UNPKG

twing

Version:

First-class Twig engine for Node.js

31 lines (30 loc) 2.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.executeAttributeAccessorNodeSynchronously = exports.executeAttributeAccessorNode = void 0; const traceable_method_1 = require("../../helpers/traceable-method"); const get_attribute_1 = require("../../helpers/get-attribute"); const executeAttributeAccessorNode = (node, executionContext) => { const { template, sandboxed, environment, nodeExecutor: execute, strict } = executionContext; const { target, attribute, arguments: methodArguments } = node.children; const { type, shouldIgnoreStrictCheck, shouldTestExistence } = node.attributes; return Promise.all([ execute(target, executionContext), execute(attribute, executionContext), execute(methodArguments, executionContext) ]).then(([target, attribute, methodArguments]) => { const traceableGetAttribute = (0, traceable_method_1.getTraceableMethod)(get_attribute_1.getAttribute, node, template.source); return traceableGetAttribute(environment, target, attribute, methodArguments, type, shouldTestExistence, shouldIgnoreStrictCheck || null, sandboxed, strict); }); }; exports.executeAttributeAccessorNode = executeAttributeAccessorNode; const executeAttributeAccessorNodeSynchronously = (node, executionContext) => { const { template, sandboxed, environment, nodeExecutor: execute, strict } = executionContext; const { target: targetNode, attribute: attributeNode, arguments: argumentsNode } = node.children; const { type, shouldIgnoreStrictCheck, shouldTestExistence } = node.attributes; const target = execute(targetNode, executionContext); const attribute = execute(attributeNode, executionContext); const methodArguments = execute(argumentsNode, executionContext); const traceableGetAttribute = (0, traceable_method_1.getSynchronousTraceableMethod)(get_attribute_1.getAttributeSynchronously, node, template.source); return traceableGetAttribute(environment, target, attribute, methodArguments, type, shouldTestExistence, shouldIgnoreStrictCheck || null, sandboxed, strict); }; exports.executeAttributeAccessorNodeSynchronously = executeAttributeAccessorNodeSynchronously;