The replace filter breaks when the variable is undefined.

It throws the following error:

An exception has been thrown during the rendering of a template ("s.getTemplateLine is not a function")

The difference in behaviour can be seen at:

https://cdpn.io/codebymikey/debug/jOWwpwR/XBkGRqXWjWKA vs https://twigfiddle.com/ljg25g

twing was also configured with strict_variables: false, so there's a difference in behaviour somewhere with regards to how undefined/null variables are handled in the PHP version compared to the Javascript version.

It might also be worth adding a check around e.getTemplateLine to check if the function exists before trying to call it - it'd make it easier to know the root cause of the exception.

edit: The issue is with locutus' strtr implementation.

TypeError: Cannot read property 'length' of null
    at strtr (/project/path/node_modules/locutus/php/strings/strtr.js:68:16)
    at _do (/project/path/node_modules/twing/dist/cjs/lib/extension/core/filters/replace.js:23:16)
    at replace (/project/path/node_modules/twing/dist/cjs/lib/extension/core/filters/replace.js:26:32)
    at /project/path/node_modules/twing/dist/cjs/lib/callable-wrapper.js:46:29
    at Object.doDisplay (eval at getTemplatesModule (/project/path/node_modules/twing/dist/cjs/lib/environment.js:489:24), <anonymous>:29:593)
    at async Promise.all (index 1)
    at async testTwigTemplates (/project/path/scripts/twig-tester.js:204:5)

We should be able to work around the issue by checking it's not empty before passing it to strtr.

Edited by Eric MORAND
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information