I have a few set of templates written with Twig. I have then written a separate script to be run using the CLI. This script allows me to scan my templates and compile my Assetic assets.
The problem is that I have a few custom Twig token parsers to be used by the application, however, they are not needed by the script to scan and compile my Assets. Some of these tags are quite complicated and require the full application to function.
Is there a simple way to get Twig to ignore unknown tags?
One possible solution would be to create a dummy token parser and give it the same name as the tag, but this seems very hackish to me and I would like to avoid going down this path.
I simply wrote a token parser that moves the token parser to the end of the block.
I also included a way to set the 'token name' in the constructor:
This would allow the DummyTokenParser to take over for the tags called
One can use it to replace multiple types of tags:
$twig->addTokenParser(new DummyTokenParser('tag1')); $twig->addTokenParser(new DummyTokenParser('tag2'));