12
12
use Exception ;
13
13
use LibXMLError ;
14
14
15
- use WMDE \VueJsTemplating \FilterExpressionParsing \FilterParser ;
16
15
use WMDE \VueJsTemplating \JsParsing \BasicJsExpressionParser ;
17
16
use WMDE \VueJsTemplating \JsParsing \CachingExpressionParser ;
18
17
use WMDE \VueJsTemplating \JsParsing \JsExpressionParser ;
19
18
20
19
class Component {
21
20
22
- private $ filterParser ;
23
-
24
21
/**
25
22
* @var string HTML
26
23
*/
27
24
private $ template ;
28
25
29
- /**
30
- * @var callable[]
31
- */
32
- private $ filters = [];
33
-
34
26
/**
35
27
* @var JsExpressionParser
36
28
*/
37
29
private $ expressionParser ;
38
30
39
31
/**
40
32
* @param string $template HTML
41
- * @param callable[] $filters
33
+ * @param callable[] $methods
42
34
*/
43
- public function __construct ( $ template , array $ filters ) {
35
+ public function __construct ( $ template , array $ methods ) {
44
36
$ this ->template = $ template ;
45
- $ this ->filters = $ filters ;
46
- $ this ->expressionParser = new CachingExpressionParser ( new BasicJsExpressionParser () );
47
- $ this ->filterParser = new FilterParser ();
37
+ $ this ->expressionParser = new CachingExpressionParser ( new BasicJsExpressionParser ( $ methods ) );
48
38
}
49
39
50
40
/**
@@ -161,8 +151,7 @@ private function replaceMustacheVariables( DOMNode $node, array $data ) {
161
151
preg_match_all ( $ regex , $ text , $ matches );
162
152
163
153
foreach ( $ matches ['expression ' ] as $ index => $ expression ) {
164
- $ value = $ this ->filterParser ->parse ( $ expression )
165
- ->toExpression ( $ this ->expressionParser , $ this ->filters )
154
+ $ value = $ this ->expressionParser ->parse ( $ expression )
166
155
->evaluate ( $ data );
167
156
168
157
$ text = str_replace ( $ matches [0 ][$ index ], $ value , $ text );
@@ -182,8 +171,7 @@ private function handleAttributeBinding( DOMElement $node, array $data ) {
182
171
continue ;
183
172
}
184
173
185
- $ value = $ this ->filterParser ->parse ( $ attribute ->value )
186
- ->toExpression ( $ this ->expressionParser , $ this ->filters )
174
+ $ value = $ this ->expressionParser ->parse ( $ attribute ->value )
187
175
->evaluate ( $ data );
188
176
189
177
$ name = substr ( $ attribute ->name , 1 );
0 commit comments