Skip to content

Commit 0444ace

Browse files
committed
New: Add plain HTML option
1 parent e8d9633 commit 0444ace

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

Classes/Eel/Helper/IncludeAssetsHelper.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ class IncludeAssetsHelper implements ProtectedContextAwareInterface
2121

2222
public function parseFilename(string $string): ?array
2323
{
24+
// The string is a plain html tag
25+
if (str_starts_with($string, '<') && str_ends_with($string, '>')) {
26+
return [
27+
'type' => 'PLAIN',
28+
'markup' => $string,
29+
];
30+
}
31+
2432
$types = array('html', 'js', 'css', 'mjs', 'resourcehint', 'preloadasset', 'preloadcss', 'preloadscript', 'modulepreload');
2533
// 1 => Filename
2634
// 2 => Search string
@@ -88,7 +96,7 @@ public function parseFilename(string $string): ?array
8896
if ($key != 'src') {
8997
$object['attributes'] .= ' ' . $key . $value;
9098
}
91-
} else if ($key != 'href' && $key != 'rel') {
99+
} elseif ($key != 'href' && $key != 'rel') {
92100
// CSS and Preload files
93101
$object['attributes'] .= ' ' . $key . $value;
94102
}

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ Carbon:
6868
HeadStart:
6969
- Favicons.html
7070

71+
# If a string starts with < and ends with an >, it get's inlucded as plain HTML
72+
- <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
73+
7174
# These assets get loaded in the <head> (at the end)
7275
Head:
7376
# Preload this Javascript

Resources/Private/Fusion/External/File.fusion

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,23 @@ prototype(Carbon.IncludeAssets:File) < prototype(Neos.Fusion:Component) {
3030
fileObject = ${Carbon.IncludeAssets.parseFilename(props.file)}
3131
assetKey = ${this.fileObject.inline ? 'Inline' : 'File'}
3232
type = ${this.fileObject.type}
33+
isPlain = ${this.type == 'PLAIN'}
3334
finalAssetPath = ${props.assetPath || props.paths[this.assetKey][this.type]}
3435
path = ${this.fileObject.external || this.fileObject.path ? this.fileObject.filename : this.assetPackage && this.finalAssetPath ? 'resource://' + this.assetPackage + '/' + this.finalAssetPath + '/' + this.fileObject.filename : false}
36+
path.@if.isNotPlain = ${!this.isPlain}
3537

36-
@if.hasPath = ${this.path}
38+
@if.hasPath = ${this.isPlain || this.path}
3739

3840
renderer = Neos.Fusion:Case {
3941
@process.wrapper = Carbon.IncludeAssets:Internal.Wrapper {
4042
wrapper = ${props.wrapper}
4143
}
4244

45+
isPlain {
46+
condition = ${props.isPlain}
47+
renderer = ${props.fileObject.markup}
48+
}
49+
4350
inlineFile {
4451
condition = ${props.fileObject.inline}
4552
renderer = Carbon.IncludeAssets:Internal.InlineFile {

0 commit comments

Comments
 (0)