-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
File.fusion
79 lines (68 loc) · 3.48 KB
/
File.fusion
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* This prototype outputs the tag for including HTML, JS, MJS or CSS
*/
prototype(Carbon.IncludeAssets:File) < prototype(Neos.Fusion:Component) {
@propTypes {
file = ${PropTypes.string}
assetPackage = ${PropTypes.string}
cacheBuster = ${PropTypes.boolean}
disableCacheBusterForPreloadAsset = ${PropTypes.boolean}
assetPath = ${PropTypes.string}
wrapper = ${PropTypes.string}
}
file = ${null}
assetPackage = ${node.context.currentSite.siteResourcesPackageKey}
cacheBuster = ${Configuration.setting('Carbon.IncludeAssets.Default.CacheBuster')}
disableCacheBusterForPreloadAsset = ${Configuration.setting('Carbon.IncludeAssets.Default.DisableCacheBusterForPreloadAsset')}
assetPath = ${null}
wrapper = ${null}
// This is a internal variable, please use `assetPath` for an single file
paths = ${Configuration.setting('Carbon.IncludeAssets.Default.Path')}
@if.fileIsSet = ${this.file}
renderer = Neos.Fusion:Component {
@apply.props = ${props}
fileObject = ${Carbon.IncludeAssets.parseFilename(props.file)}
assetKey = ${this.fileObject.inline ? 'Inline' : 'File'}
type = ${this.fileObject.type}
isPlain = ${this.type == 'PLAIN'}
finalAssetPath = ${props.assetPath || props.paths[this.assetKey][this.type]}
path = ${this.fileObject.external || this.fileObject.path ? this.fileObject.filename : this.assetPackage && this.finalAssetPath ? 'resource://' + this.assetPackage + '/' + this.finalAssetPath + '/' + this.fileObject.filename : false}
path.@if.isNotPlain = ${!this.isPlain}
@if.hasPath = ${this.isPlain || this.path}
renderer = Neos.Fusion:Case {
@process.wrapper = Carbon.IncludeAssets:Internal.Wrapper {
wrapper = ${props.wrapper}
}
isPlain {
condition = ${props.isPlain}
renderer = ${props.fileObject.markup}
}
inlineFile {
condition = ${props.fileObject.inline}
renderer = Carbon.IncludeAssets:Internal.InlineFile {
attributes = ${props.fileObject.attributes}
path = ${props.path}
type = ${props.type}
}
}
isFile {
condition = ${props.path ? true : false}
renderer = Carbon.IncludeAssets:Internal.TypeCase {
type = ${props.type}
css = afx`
<Carbon.IncludeAssets:Internal.Tag.CSS path={props.path} fileObject={props.fileObject} cacheBuster={props.cacheBuster} async={this.fileObject.async ? node.context.live : false} />
`
js = afx`
<Carbon.IncludeAssets:Internal.Tag.JS path={props.path} fileObject={props.fileObject} cacheBuster={props.cacheBuster} />
`
preload = afx`
<Carbon.IncludeAssets:Internal.Tag.ResourceHint rel='preload' path={props.path} fileObject={props.fileObject} cacheBuster={props.cacheBuster} disableCacheBusterForPreloadAsset={props.disableCacheBusterForPreloadAsset} />
`
modulePreload = afx`
<Carbon.IncludeAssets:Internal.Tag.ResourceHint rel='modulepreload' path={props.path} fileObject={props.fileObject} cacheBuster={props.cacheBuster} />
`
}
}
}
}
}