Skip to content

Commit f2ea110

Browse files
committed
Add documentation for scriptStart/scriptEnd
Refs #18878
1 parent a3ca856 commit f2ea110

2 files changed

Lines changed: 33 additions & 7 deletions

File tree

en/appendices/5-3-migration-guide.rst

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,6 @@ Routing
127127
enum backed properties as route parameters. When an enum backed property is
128128
used in routing, the enum's ``value`` or ``name`` will be used.
129129

130-
Validation
131-
----------
132-
133-
- ``ipOrRange()`` validation has has been added to check for an IP or a range (subnet).
134-
- When validating within CakePHP marshalling context, the entity will be passed into the ``context`` argument for use inside custom validation rules.
135-
This can be useful when patching partially and then needing to get that data from the entity instead of the passed data.
136-
137130
TestSuite
138131
---------
139132

@@ -146,3 +139,18 @@ Utility
146139
- ``Text::uuid()`` now supports configurable UUID generation. You can set a custom
147140
UUID generator using ``Configure::write('Text.uuidGenerator', $closure)`` to
148141
integrate your own UUID generation strategy or third-party libraries.
142+
143+
Validation
144+
----------
145+
146+
- ``ipOrRange()`` validation has has been added to check for an IP or a range (subnet).
147+
- When validating within CakePHP marshalling context, the entity will be passed into the ``context`` argument for use inside custom validation rules.
148+
This can be useful when patching partially and then needing to get that data from the entity instead of the passed data.
149+
150+
View
151+
----
152+
153+
- :php:meth:`HtmlHelper::scriptStart()` and ``scriptEnd()`` now allow simple
154+
wrapping script tags (``<script>...</script>``) around inline JavaScript. This
155+
enables syntax highlighting in many editors to work. The wrapping script tag
156+
will be removed and replaced with a script tag generated by the helper.

en/views/helpers/html.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,12 +555,30 @@ or buffered into a block::
555555
echo "alert('I am in the JavaScript');";
556556
$this->Html->scriptEnd();
557557

558+
You can use simple ``<script>...</script>`` tags inside the script block to
559+
enable syntax highlighting and LSP support in many editors::
560+
561+
<?php $this->Html->scriptStart(['block' => true]) ?>
562+
<script>
563+
document.addEventListener('DOMContentLoaded', function() {
564+
alert('I am in the JavaScript');
565+
});
566+
</script>
567+
<?php $this->Html->scriptEnd() ?>
568+
569+
The wrapping ``script``tag will be removed and replaced with a script tag
570+
generated by the helper that includes a CSP nonce if available.
571+
558572
Once you have buffered javascript, you can output it as you would any other
559573
:ref:`View Block <view-blocks>`::
560574
561575
// In your layout
562576
echo $this->fetch('script');
563577
578+
.. versionchanged:: 5.3.0
579+
Support for ``script`` tags inside ``scriptStart()``/``scriptEnd()`` was
580+
added.
581+
564582
Creating Javascript Importmap
565583
-----------------------------
566584

0 commit comments

Comments
 (0)