Closed ericmorand closed 3 years ago
@adambrgmn, you should now be able to parse a template in a "loose" way - that is without the parser checking if functions, filters or tests are registered - by passing {strict: false}
as second parameter to TwingParser
constructor.
Twig langage unfortunately permits to customize the core specification of the language by adding global functions, filters and tests. Even though it is strongly recommended to not take advantage of this design oversight - and provide customization at runtime through the context passed when rendering a template, a lot of frameworks have unfortunately based their templating engine on the usage of those global "callables": Drupal, Wordpress, Symfony...
Currently, Twing parser throws an error if an unknown "callable" is encountered while parsing the template, making impossible to parse templates using custom callables without knowing before-hand the complete list of those callables.
To overcome the issue, we need to allow the parser to function in a "loose" way where it doesn't fail when encountering an unknown callable.
Discussed in https://github.com/NightlyCommit/twing/discussions/540