public class ResourcesTemplatingFunctions extends Object
Provide a single pattern or a list of patterns to match files from all resources. Use methods css(String)
,
css(List)
, cachedCss(String)
, cachedCss(List)
, js(String)
, js(List)
,
cachedJs(String)
or cachedJs(List)
demanding on your needs.
The methods create printable html tags such as the followings:
<script src="/.resources/travel-demo-theme/js/html5shiv.js"></script>
<link rel="stylesheet" type="text/css" href="/.resources/foobar/webresources/css/a.css"/>
<link rel="stylesheet" type="text/css" media="all" href="/.resources/foobar/webresources/css/a~2016-12-08-02-56-06-000~cache.css"/>
Example calls:
${resfn.css("/travel-demo-theme.*css")} (single pattern) ${resfn.js("/travel-demo-theme.*js")} (single pattern) ${resfn.css(["/foobar.*css", ".*magnolia.*css"])} (pattern list) ${resfn.css(["/foobar.*css", ".*magnolia.*css"], "media='all'")} (pattern list and other properties argument with single quotes) ${resfn.css(["/foobar.*css", ".*magnolia.*css"], "media=\"all\"")} (pattern list and other properties argument with escaped double quotes) ${resfn.cachedJs(["/foobar/.*.js", "/travel-demo/.*.js"])} (call to cached files)
This templating functions class originates from the project neat-resources by rah003@github.com.
Modifier and Type | Field and Description |
---|---|
protected static String |
CSS_SUFFIX |
protected static String |
JS_PREFIX |
protected static String |
JS_SUFFIX |
static String |
NAME |
Constructor and Description |
---|
ResourcesTemplatingFunctions(info.magnolia.resourceloader.ResourceOrigin resourceOrigin,
info.magnolia.module.resources.ResourceLinker linker) |
Modifier and Type | Method and Description |
---|---|
String |
cachedCss(List<String> patterns)
Generates cached css links for all css files matching the provided pattern(s).
|
String |
cachedCss(List<String> patterns,
String otherAttributes)
Generates cached css links for all css files matching the provided pattern(s); css links will contain the provided other attributes.
|
String |
cachedCss(String pattern)
Generates cached css links for all css files matching the provided pattern.
|
String |
cachedCss(String pattern,
String otherAttributes)
Generates cached css links for all css files matching the provided pattern; css links will contain the provided other attributes.
|
String |
cachedJs(List<String> patterns)
Generates cached js links for all js files matching the provided pattern(s).
|
String |
cachedJs(String pattern)
Generates cached js links for all js files matching the provided pattern.
|
String |
css(List<String> patterns)
Generates css links for all css files matching the provided pattern(s).
|
String |
css(List<String> patterns,
String otherAttributes)
Generates css links for all css files matching the provided pattern(s); css links will contain the provided other attributes.
|
String |
css(String pattern)
Generates css links for all css files matching the provided pattern.
|
String |
css(String pattern,
String otherAttributes)
Generates css links for all css files matching the provided pattern; css links will contain the provided other attributes.
|
String |
js(List<String> patterns)
Generates js links for all js files matching provided pattern(s).
|
String |
js(String pattern)
Generates js links for all js files matching the provided pattern.
|
public static final String NAME
protected static final String CSS_SUFFIX
protected static final String JS_PREFIX
protected static final String JS_SUFFIX
@Inject public ResourcesTemplatingFunctions(info.magnolia.resourceloader.ResourceOrigin resourceOrigin, info.magnolia.module.resources.ResourceLinker linker)
public String css(String pattern)
public String css(String pattern, String otherAttributes)
public String css(List<String> patterns)
public String css(List<String> patterns, String otherAttributes)
public String cachedCss(String pattern)
public String cachedCss(String pattern, String otherAttributes)
public String cachedCss(List<String> patterns)
public String cachedCss(List<String> patterns, String otherAttributes)
public String js(String pattern)
public String js(List<String> patterns)
public String cachedJs(String pattern)
Copyright © 2018 Magnolia International Ltd.. All rights reserved.