ScriptTag final class
Minn\Support\ScriptTag · public/minn/src/Minn/Support/ScriptTag.php · 69 lines
Script elements as the reference builds them (probe script-tags): the attributes sorted by name, a src or href through esc_url and every other value escaped (true or null printed bare, false left out); inline code between newlines, with any "<script" or "</script" that would end or open an element written with its "s" as a \u escape. Only JavaScript and JSON can carry that escape: a script of another type whose code holds such a sequence is not printed at all.
Constants and properties
| private | ESCAPABLE = array ( 0 => '', 1 => 'module', 2 => 'application/json', 3 => 'importmap', 4 => 'speculationrules', 5 => 'application/ecmascript', 6 => 'application/javascript', 7 => 'application/x-ecmascript', 8 => 'application/x-javascript', 9 => 'text/ecmascript', 10 => 'text/javascript', 11 => 'text/javascript1.0', 12 => 'text/javascript1.1', 13 => 'text/javascript1.2', 14 => 'text/javascript1.3', 15 => 'text/javascript1.4', 16 => 'text/javascript1.5', 17 => 'text/jscript', 18 => 'text/livescript', 19 => 'text/x-ecmascript', 20 => 'text/x-javascript', ) | The script types inline code is JavaScript or JSON in (lowercase, trimmed; no type at all counts as JavaScript). |
| private | TAG = '#<(/?)(s)(cript[\\t\\n\\f\\r />])#i' | A sequence that would open or close a script element inside one. |
Public
| static | element(array $attributes): string# | The empty element for a script file.
| |||
| static | inline(string $code, array $attributes): string# | The element for inline code (already between its newlines), or '' when its type cannot hold the code safely.
|
Internals 1
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | attributes(array $attributes): string# | The attributes as markup, each with its leading space.
|
Nothing matches.