Skip to content

Commit cfddb7f

Browse files
Add ability to add twig namespaces ala @Atoms
To use, add app.config.namespaces as a yaml associative array to .pk-config.yml Then you can reference your @namespace in a twig template
1 parent 280179b commit cfddb7f

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/app.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,20 @@
8787
),
8888
));
8989

90+
//// Register twig namespaces
91+
/**
92+
* app.config.namespaces is a yaml associative array
93+
* ...
94+
* namespaces:
95+
* atoms: _patterns/atoms
96+
* molecules: _patterns/molecules
97+
*/
98+
if (is_array($app['config']['namespaces'])) {
99+
foreach ($app['config']['namespaces'] as $key => $value) {
100+
$app['twig.loader.filesystem']->addPath(realpath('./' . $value), $key);
101+
}
102+
}
103+
90104

91105
// Custom Functions
92106

0 commit comments

Comments
 (0)