Skip to content

Commit d885671

Browse files
committed
making sure files with underscores are ignored like the rest of PL
1 parent 074b9c1 commit d885671

File tree

1 file changed

+59
-22
lines changed

1 file changed

+59
-22
lines changed

src/PatternLab/PatternEngine/Twig/TwigUtil.php

Lines changed: 59 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,18 @@ public static function loadFilters($instance) {
8383
$finder->sortByName();
8484
foreach ($finder as $file) {
8585

86-
include($file->getPathname());
87-
88-
// $filter should be defined in the included file
89-
if (isset($filter)) {
90-
$instance->addFilter($filter);
91-
unset($filter);
86+
// see if the file should be ignored or not
87+
$baseName = $file->getBasename();
88+
if ($baseName[0] != "_") {
89+
90+
include($file->getPathname());
91+
92+
// $filter should be defined in the included file
93+
if (isset($filter)) {
94+
$instance->addFilter($filter);
95+
unset($filter);
96+
}
97+
9298
}
9399

94100
}
@@ -124,12 +130,18 @@ public static function loadFunctions($instance) {
124130
$finder->sortByName();
125131
foreach ($finder as $file) {
126132

127-
include($file->getPathname());
128-
129-
// $function should be defined in the included file
130-
if (isset($function)) {
131-
$instance->addFunction($function);
132-
unset($function);
133+
// see if the file should be ignored or not
134+
$baseName = $file->getBasename();
135+
if ($baseName[0] != "_") {
136+
137+
include($file->getPathname());
138+
139+
// $function should be defined in the included file
140+
if (isset($function)) {
141+
$instance->addFunction($function);
142+
unset($function);
143+
}
144+
133145
}
134146

135147
}
@@ -164,7 +176,16 @@ public static function loadMacros($instance) {
164176
$finder->files()->name("*.".$macroExt)->in($macroDir);
165177
$finder->sortByName();
166178
foreach ($finder as $file) {
167-
$instance->addGlobal($file->getBasename(".".$macroExt), $instance->loadTemplate($file->getBasename()));
179+
180+
// see if the file should be ignored
181+
$baseName = $file->getBasename();
182+
if ($baseName[0] != "_") {
183+
184+
// add the macro to the global context
185+
$instance->addGlobal($file->getBasename(".".$macroExt), $instance->loadTemplate($baseName));
186+
187+
}
188+
168189
}
169190

170191
} else {
@@ -197,9 +218,19 @@ public static function loadTags($instance) {
197218
$finder->files()->name("*\.".$tagExt)->in($tagDir);
198219
$finder->sortByName();
199220
foreach ($finder as $file) {
200-
include($file->getPathname());
201-
$className = "Project_".$file->getBasename(".".$tagExt)."_TokenParser";
202-
$instance->addTokenParser(new $className());
221+
222+
// see if the file should be ignored or not
223+
$baseName = $file->getBasename();
224+
if ($baseName[0] != "_") {
225+
226+
include($file->getPathname());
227+
228+
// Project_{filenameBase}_TokenParser should be defined in the include
229+
$className = "Project_".$file->getBasename(".".$tagExt)."_TokenParser";
230+
$instance->addTokenParser(new $className());
231+
232+
}
233+
203234
}
204235

205236
} else {
@@ -233,12 +264,18 @@ public static function loadTests($instance) {
233264
$finder->sortByName();
234265
foreach ($finder as $file) {
235266

236-
include($file->getPathname());
237-
238-
// $test should be defined in the included file
239-
if (isset($test)) {
240-
$instance->addTest($test);
241-
unset($test);
267+
// see if the file should be ignored or not
268+
$baseName = $file->getBasename();
269+
if ($baseName[0] != "_") {
270+
271+
include($file->getPathname());
272+
273+
// $test should be defined in the included file
274+
if (isset($test)) {
275+
$instance->addTest($test);
276+
unset($test);
277+
}
278+
242279
}
243280

244281
}

0 commit comments

Comments
 (0)