Function in extends block results in javascript SyntaxError
The following piece of code is declared at the top of a twig file
{% extends config("package_info") == "Page" ? "layout.html" : "modal.twig" %}
When the module gets loaded Twing produces the following error:
SyntaxError: missing ) after argument list
at new Function (<anonymous>)
at TwingEnvironmentNode.getTemplatesModule (/usr/src/app/node_modules/twing/dist/cjs/lib/environment.js:491:24)
at /usr/src/app/node_modules/twing/dist/cjs/lib/environment.js:328:76
at processTicksAndRejections (node:internal/process/task_queues:95:5)
This is the declaration of the config function:
const loader = new TwingLoaderArray(content)
const env = new TwingEnvironment(loader, {
cache: false
})
env.addFunction(new TwingFunction(
'url',
(key) => Promise.resolve(vars[key]),
[{name: 'key', defaultValue: ''}]
))
I have tried to resolve this myself but have hit a wall, it seems to be just the fault of Twing from my testing. When replacing the ternary operator with just one of the layout file names the template does render perfectly.
Edited by Justin Schreiber