File tree Expand file tree Collapse file tree 3 files changed +16
-4
lines changed
Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ class Script extends Tag
88{
99 public string $ tag = 'script ' ;
1010
11+ protected bool $ escape = false ;
12+
1113 public function __construct (
1214 public ?string $ type = null ,
1315 public ?string $ content = null ,
Original file line number Diff line number Diff line change @@ -6,8 +6,12 @@ abstract class Tag extends TagVoid
66{
77 public ?string $ content = null ;
88
9+ protected bool $ escape = true ;
10+
911 public function toHtml (): string
1012 {
11- return "< {$ this ->tag } {$ this ->toProperties ()->join (' ' )}> {$ this ->content }</ {$ this ->tag }> " ;
13+ $ content = $ this ->escape ? e ($ this ->content , false ) : $ this ->content ;
14+
15+ return "< {$ this ->tag } {$ this ->toProperties ()->join (' ' )}> {$ content }</ {$ this ->tag }> " ;
1216 }
1317}
Original file line number Diff line number Diff line change @@ -22,10 +22,16 @@ abstract class TagVoid implements Htmlable
2222 */
2323 public function toProperties (): Collection
2424 {
25+ if (! $ this ->properties ) {
26+ return new Collection ;
27+ }
28+
2529 return $ this ->properties
26- ?->map(fn (?string $ value ) => $ value ? trim ($ value ) : null )
27- ->map (fn (?string $ value , string $ property ) => "{$ property }= \"{$ value }\"" )
28- ?? new Collection ;
30+ ->map (function (string $ value , string $ property ) {
31+ $ value = e (trim ($ value ));
32+
33+ return "{$ property }= \"{$ value }\"" ;
34+ });
2935 }
3036
3137 public function toHtml (): string
You can’t perform that action at this time.
0 commit comments