pattern-lab / patternengine-php-twig

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

adding namespaces to top level folders (i.e. @atoms) #24

Closed EvanLovely closed 8 years ago

EvanLovely commented 8 years ago

Adding this would let PL use Twig Namespaces (i.e. {% include "@atoms/forms/submit.twig" %} ) for templates as an alternative to the Pattern Partial Syntax ({% include "atoms-submit" %}). The reason behind this is that we are able to register namespaces in other systems (like Drupal using the components module) and then have both systems digest the same templates.

This change would register a namespace for each top level folder under source/_patterns/. Assuming the classic top levels folders of atoms, molecules, etc were used; this would create the following namespaces, essentially little "shortcuts" to each directory:

Assuming I had this folder structure:

I could then include it with {% include "@atoms/forms/submit.twig" %}. THAT WOULD BE AWESOME!

Could we get this in? Anything I need to change? THANKS!!!

dmolsen commented 8 years ago

Implemented this in TwigUtil and took a little different tact on some things. I've tried to avoid preg_replace throughout as a nod to perf.