pattern-lab / patternengine-php-twig

Twig-based PatternEngine for Pattern Lab.
http://patternlab.io/
MIT License
78 stars 36 forks source link

Throwing error on uncompiled templates #33

Closed EvanLovely closed 8 years ago

EvanLovely commented 8 years ago

When a Twig template contains a namespace powered path like {% include "@atoms/buttons/button.twig" %} and the file is not present, then there is no error thrown currently and the outputted Pattern simply contains this:

2016-10-12 at 2 29 pm

Silent errors are the worst. This is caused by Twig_Loader_String being the last Twig Loader in the Twig_Loader_Chain and will try to render anything thrown at it and is simply doing that above. This PR ensures that if any rendered result starts with @, then an error is thrown. I consider it a stopgap until Twig_Loader_Chain is removed as it is currently deprecated and even contains the internal note to "NEVER use".