Skip to content

Commit

Permalink
script_tag: changelog, doc + test with default arg
Browse files Browse the repository at this point in the history
  • Loading branch information
xlii-chl committed Apr 18, 2022
1 parent a8d5b89 commit c167f16
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions system/Helpers/html_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ function doctype(string $type = 'html5'): string
*
* Generates link to a JS file
*
* @param mixed $src Script source or an array
* @param bool $indexPage Should indexPage be added to the JS path
* @param array|string $src Script source or an array of attributes
* @param bool $indexPage Should indexPage be added to the JS path
*/
function script_tag($src = '', bool $indexPage = false): string
{
Expand Down
10 changes: 10 additions & 0 deletions tests/system/Helpers/HTMLHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,16 @@ public function testScriptTagWithSrcAndAttributes()
$this->assertSame($expected, script_tag($target));
}

/**
* This test has probably no real-world value but may help detecting
* a change in the default behaviour.
*/
public function testScriptTagWithoutAnyArg()
{
$expected = '<script src="http://example.com/" type="text/javascript"></script>';
$this->assertSame($expected, script_tag());
}

public function testLinkTag()
{
$target = 'css/mystyles.css';
Expand Down
1 change: 1 addition & 0 deletions user_guide_src/source/changelogs/v4.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Enhancements
- The log format has also changed. If users are depending on the log format in their apps, the new log format is "<1-based count> <cleaned filepath>(<line>): <class><function><args>"
- Added support for webp files to **app/Config/Mimes.php**.
- Added 4th parameter ``$includeDir`` to ``get_filenames()``. See :php:func:`get_filenames`.
- HTML helper ``script_tag()`` now uses ``null`` values to write boolean attributes in minimized form: ``<script src="..." defer />``. See the sample code for :php:func:`script_tag`.

Changes
*******
Expand Down
4 changes: 2 additions & 2 deletions user_guide_src/source/helpers/html_helper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ The following functions are available:

.. php:function:: script_tag([$src = ''[, $indexPage = false]])
:param mixed $src: The source name of a JavaScript file
:param bool $indexPage: Whether to treat ``$src`` as a routed URI string
:param array|string $src: The source name or URL of a JavaScript file, or an associative array specifying the attributes
:param bool $indexPage: Whether to treat ``$src`` as a routed URI string
:returns: HTML script tag
:rtype: string

Expand Down

0 comments on commit c167f16

Please sign in to comment.