UNPKG

twing

Version:

First-class Twig engine for Node.js

29 lines (28 loc) 1.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createWithTagHandler = void 0; const with_1 = require("../node/with"); const createWithTagHandler = () => { const tag = 'with'; return { tag, initialize: (parser) => { return (token, stream) => { let variables = null; let only = false; if (!stream.test("TAG_END")) { variables = parser.parseExpression(stream); only = stream.nextIf("NAME", 'only') !== null; } stream.expect("TAG_END"); let body = parser.subparse(stream, tag, (token) => { return token.test("NAME", 'endwith'); }); stream.next(); stream.expect("TAG_END"); return (0, with_1.createWithNode)(body, variables, only, token.line, token.column, tag); }; } }; }; exports.createWithTagHandler = createWithTagHandler;