Project

General

Profile

Actions

Feature #99510

closed

ScriptViewHelper and CssViewHelper miss file to inline rendering option

Added by Tanel Põld almost 2 years ago. Updated about 1 month ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Fluid
Start date:
2023-01-10
Due date:
% Done:

100%

Estimated time:
PHP Version:
Tags:
inline, css, javascript, f:asset
Complexity:
Sprint Focus:

Description

f:asset.css and f:asset.script are great but miss an option to render inline from files.
This would help keeping JavaScript and CSS out of XML files in case one desires rendering it inline.

So for example this CSS file would be loaded inline:

<f:asset.css identifier="extensionName" inline href="EXT:extensionname/Resources/Public/Css/extensionname.css" />

Probably not so simple but...
Registering the 'inline' attribute and then adding a condition something like this in:
typo3/sysext/fluid/Classes/ViewHelpers/Asset/CssViewHelper.php

if ($file !== null) {
    if ($inline) {
        $content = (string)file_get_contents(GeneralUtility::getFileAbsFileName(trim($file)));
        $this->assetCollector->addInlineStyleSheet($identifier, $content, $attributes, $options);
    } else {
        $this->assetCollector->addStyleSheet($identifier, $file, $attributes, $options);
    }
}
Actions

Also available in: Atom PDF