create-prisma-php-app 1.26.530 → 1.26.531
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -67,25 +67,39 @@ class PHPX implements IPHPX
|
|
|
67
67
|
/**
|
|
68
68
|
* Generates and returns a string of HTML attributes from the provided props.
|
|
69
69
|
* Excludes 'class' and 'children' props from being added as attributes.
|
|
70
|
-
*
|
|
71
|
-
*
|
|
70
|
+
* Prioritizes attributes from `$this->props` if duplicates are found in `$params`.
|
|
71
|
+
*
|
|
72
|
+
* @param array $params Optional additional attributes to merge with props.
|
|
73
|
+
*
|
|
74
|
+
* @return string The generated HTML attributes as a space-separated string.
|
|
72
75
|
*/
|
|
73
|
-
protected function getAttributes(): string
|
|
76
|
+
protected function getAttributes(array $params = []): string
|
|
74
77
|
{
|
|
75
78
|
// Filter out 'class' and 'children' props
|
|
76
|
-
$filteredProps = array_filter(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
$filteredProps = array_filter(
|
|
80
|
+
$this->props,
|
|
81
|
+
function ($key) {
|
|
82
|
+
return !in_array($key, ["class", "children"]);
|
|
83
|
+
},
|
|
84
|
+
ARRAY_FILTER_USE_KEY
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
// Merge attributes, prioritizing props in case of duplicates
|
|
88
|
+
$attributes = array_merge($params, $filteredProps);
|
|
79
89
|
|
|
80
|
-
// Build attributes string by escaping keys and values
|
|
81
|
-
$
|
|
82
|
-
foreach ($
|
|
83
|
-
$escapedKey = htmlspecialchars($key, ENT_QUOTES,
|
|
84
|
-
$escapedValue = htmlspecialchars(
|
|
85
|
-
|
|
90
|
+
// Build the attributes string by escaping keys and values
|
|
91
|
+
$attributeStrings = [];
|
|
92
|
+
foreach ($attributes as $key => $value) {
|
|
93
|
+
$escapedKey = htmlspecialchars($key, ENT_QUOTES, "UTF-8");
|
|
94
|
+
$escapedValue = htmlspecialchars(
|
|
95
|
+
(string) $value,
|
|
96
|
+
ENT_QUOTES,
|
|
97
|
+
"UTF-8"
|
|
98
|
+
);
|
|
99
|
+
$attributeStrings[] = "$escapedKey='$escapedValue'";
|
|
86
100
|
}
|
|
87
101
|
|
|
88
|
-
return implode(
|
|
102
|
+
return implode(" ", $attributeStrings);
|
|
89
103
|
}
|
|
90
104
|
|
|
91
105
|
/**
|
|
@@ -37,6 +37,9 @@ class TemplateCompiler
|
|
|
37
37
|
self::initializeClassMappings();
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
// Escape `&` characters that are not part of valid XML entities
|
|
41
|
+
$templateContent = preg_replace('/&(?![a-zA-Z0-9#]+;)/', '&', $templateContent);
|
|
42
|
+
|
|
40
43
|
$dom = new DOMDocument();
|
|
41
44
|
libxml_use_internal_errors(true);
|
|
42
45
|
|