UNPKG

twing

Version:

First-class Twig engine for Node.js

28 lines (27 loc) 1.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.executePrintNodeSynchronously = exports.executePrintNode = void 0; const executePrintNode = (node, executionContext) => { const { template, nodeExecutor: execute, outputBuffer, sourceMapRuntime } = executionContext; sourceMapRuntime === null || sourceMapRuntime === void 0 ? void 0 : sourceMapRuntime.enterSourceMapBlock(node.line, node.column, node.type, template.source, outputBuffer); return execute(node.children.expression, executionContext) .then((result) => { if (Array.isArray(result)) { result = 'Array'; } outputBuffer.echo(result); sourceMapRuntime === null || sourceMapRuntime === void 0 ? void 0 : sourceMapRuntime.leaveSourceMapBlock(outputBuffer); }); }; exports.executePrintNode = executePrintNode; const executePrintNodeSynchronously = (node, executionContext) => { const { template, nodeExecutor: execute, outputBuffer, sourceMapRuntime } = executionContext; sourceMapRuntime === null || sourceMapRuntime === void 0 ? void 0 : sourceMapRuntime.enterSourceMapBlock(node.line, node.column, node.type, template.source, outputBuffer); let result = execute(node.children.expression, executionContext); if (Array.isArray(result)) { result = 'Array'; } outputBuffer.echo(result); sourceMapRuntime === null || sourceMapRuntime === void 0 ? void 0 : sourceMapRuntime.leaveSourceMapBlock(outputBuffer); }; exports.executePrintNodeSynchronously = executePrintNodeSynchronously;