File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
src/PatternLab/PatternData/Helpers Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 19
19
20
20
class LineageHelper extends \PatternLab \PatternData \Helper {
21
21
22
+ protected $ lineageMatch ;
23
+ protected $ lineageMatchKey ;
24
+
22
25
public function __construct ($ options = array ()) {
23
26
24
27
parent ::__construct ($ options );
25
28
29
+ $ this ->lineageMatch = Config::getOption ("lineageMatch " );
30
+ $ this ->lineageMatchKey = Config::getOption ("lineageMatchKey " );
31
+
26
32
}
27
33
28
34
public function run () {
@@ -160,14 +166,13 @@ public function run() {
160
166
161
167
/**
162
168
* Get the lineage for a given pattern by parsing it and matching mustache partials
163
- * @param {String} the filename for the pattern to be parsed
169
+ * @param {String} the data from the raw pattern
164
170
*
165
171
* @return {Array} a list of patterns
166
172
*/
167
- protected function findLineages ($ filename ) {
168
- $ data = file_get_contents ($ filename );
169
- if (preg_match_all ('/{{>([ ]+)?([A-Za-z0-9-_]+)(?:\:[A-Za-z0-9-]+)?(?:(| )\(.*)?([ ]+)?}}/ ' ,$ data ,$ matches )) {
170
- return array_unique ($ matches [2 ]);
173
+ protected function findLineages ($ data ) {
174
+ if (preg_match_all ("/ " .$ this ->lineageMatch ."/ " ,$ data ,$ matches )) {
175
+ return array_unique ($ matches [$ this ->lineageMatchKey ]);
171
176
}
172
177
return array ();
173
178
}
You can’t perform that action at this time.
0 commit comments