Skip to content

Commit

Permalink
EATURE] Option to skip URL processing in AssetRenderer (#5117)
Browse files Browse the repository at this point in the history
Resolves: TYPO3-Documentation/Changelog-To-Doc#1034
Releases: main, 13.4
  • Loading branch information
linawolf authored Dec 5, 2024
1 parent acb294a commit b8a71b6
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Documentation/ApiOverview/Assets/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ inserting JavaScript and CSS code.
The asset collector also collects information about images on a page,
which can be used in cached and non-cached components.

.. versionadded:: 13.3
Option `external` to skip URL processing in AssetRenderer has been added.

The :php:`AssetCollector` option `external` can be used for
asset files using :php:`$assetCollector->addStyleSheet()`
or :php:`$assetCollector->addJavaScript()`. If set all processing of the asset
URI (like the addition of the cache busting parameter) is skipped and the input
path will be used as-is in the resulting HTML tag.

.. _asset-collector-api:

The API
Expand Down Expand Up @@ -186,6 +195,24 @@ Check if a JavaScript file with the given identifier exists:
// result: false - JavaScript with identifier $identifier does not exist
}
The following code skips the cache busting parameter `?1726090820` for the supplied CSS file:

.. code-block:: php
:caption: EXT:my_extension/Classes/MyClass.php
$assetCollector->addStyleSheet(
'myCssFile',
PathUtility::getAbsoluteWebPath(GeneralUtility::getFileAbsFileName('EXT:my_extension/Resources/Public/MyFile.css')),
[],
['external' => true]
);
Resulting in the following HTML output:

.. code-block:: html

<link rel="stylesheet" href="/_assets/<hash>/myFile.css" />


.. index::
pair: Assets; Events
Expand Down

0 comments on commit b8a71b6

Please sign in to comment.