File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
src/PatternLab/PatternEngine/Twig Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -177,4 +177,38 @@ public static function loadMacros($instance) {
177177
178178 }
179179
180+ /**
181+ * Load tags for the Twig PatternEngine
182+ * @param {Instance} an instance of the twig engine
183+ *
184+ * @return {Instance} an instance of the twig engine
185+ */
186+ public static function loadTags ($ instance ) {
187+
188+ // load defaults
189+ $ tagDir = Config::getOption ("sourceDir " ).DIRECTORY_SEPARATOR ."_twig-components/tags " ;
190+ $ tagExt = Config::getOption ("twigTagExt " );
191+ $ tagExt = $ tagExt ? $ tagExt : "tag.twig " ;
192+
193+ if (is_dir ($ tagDir )) {
194+
195+ // loop through the tags and instantiate the class...
196+ $ finder = new Finder ();
197+ $ finder ->files ()->name ("*\. " .$ tagExt )->in ($ tagDir );
198+ $ finder ->sortByName ();
199+ foreach ($ finder as $ file ) {
200+ include ($ file ->getPathname ());
201+ $ className = "Project_ " .$ file ->getBasename (". " .$ tagExt )."_TokenParser " ;
202+ $ instance ->addTokenParser (new $ className ());
203+ }
204+
205+ } else {
206+
207+ self ::dirNotExist ($ tagDir );
208+
209+ }
210+
211+ return $ instance ;
212+
213+ }
180214}
You can’t perform that action at this time.
0 commit comments