@@ -14,9 +14,15 @@ public function testPlug()
14
14
'compiler_modules ' => [JsPhpizePhug::class],
15
15
]);
16
16
17
+ ob_start ();
18
+ $ php = $ compiler ->compile ('a(data-foo={message: "Hello"}) ' );
19
+ eval ('?> ' . $ php );
20
+ $ html = ob_get_contents ();
21
+ ob_end_clean ();
22
+
17
23
self ::assertSame (
18
- '<a data-foo="<?= htmlspecialchars((is_array($_pug_temp = array( \' message \' => "Hello" )) || (is_object($_pug_temp) && !method_exists($_pug_temp, "__toString")) ? json_encode($_pug_temp) : strval($_pug_temp))) ?> "></a> ' ,
19
- $ compiler -> compile ( ' a(data-foo={message: "Hello"}) ' )
24
+ '<a data-foo="{" message":"Hello"} "></a> ' ,
25
+ $ html
20
26
);
21
27
22
28
$ compiler = new Compiler ([
@@ -57,18 +63,29 @@ public function testPlug()
57
63
'compiler_modules ' => [JsPhpizePhug::class],
58
64
]);
59
65
66
+ ob_start ();
67
+ $ foo = '<a>" b="b ' ;
68
+ $ php = $ compiler ->compile ('a(foo?!=foo) ' );
69
+ eval ('?> ' . $ php );
70
+ $ html = ob_get_contents ();
71
+ ob_end_clean ();
60
72
self ::assertSame (
61
- '<a foo="<?= (is_array($_pug_temp = $foo) || (is_object($_pug_temp) && !method_exists($_pug_temp, "__toString")) ? json_encode($_pug_temp) : strval($_pug_temp)) ?> "></a> ' ,
62
- $ compiler -> compile ( ' a(foo?!=foo) ' )
73
+ '<a foo="<a>" b="b "></a> ' ,
74
+ $ html
63
75
);
64
76
65
77
$ compiler = new Compiler ([
66
78
'compiler_modules ' => [JsPhpizePhug::class],
67
79
]);
68
80
81
+ ob_start ();
82
+ $ php = $ compiler ->compile ('a(foo=array("foo" => "bar")[ \'foo \']) ' );
83
+ eval ('?> ' . $ php );
84
+ $ html = ob_get_contents ();
85
+ ob_end_clean ();
69
86
self ::assertSame (
70
- '<a foo="<?= (is_array($_pug_temp = array("foo" => " bar")[ \' foo \' ]) || (is_object($_pug_temp) && !method_exists($_pug_temp, "__toString")) ? json_encode($_pug_temp) : strval($_pug_temp)) ?> "></a> ' ,
71
- $ compiler -> compile ( ' a(foo?!=array("foo" => "bar")[ \' foo \' ]) ' )
87
+ '<a foo="bar"></a> ' ,
88
+ $ html
72
89
);
73
90
}
74
91
0 commit comments