public class ResourceBundleProcessor
extends org.thymeleaf.processor.element.AbstractElementProcessor
Takes a list of resources and optionally minifies (using the Yahoo YUI minifier) and combines them together to present a
single file in the response. This will also automatically version the file name when minifying so that changes to bundles
will not be cached by the browser. Most of the heavy lifting of this processor is done in ResourceBundlingService
which uses ResourceMinificationService.
The operation of this processor is dependent upon the bundle.enabled system property. If bundling is disabled
via this system property then each file is individually linked in the HTML source
For example, given this bundle:
<blc:bundle name="lib.js"
mapping-prefix="/js/"
files="plugins.js,
libs/jquery.MetaData.js,
libs/jquery.rating.pack.js,
libs/jquery.dotdotdot-1.5.1.js" />
With bundling enabled this will turn into:
<script type="text/javascript" src="/js/lib-123412.js" />
Where lib-123412.js is the result of minifying and combining all of the referenced files together.
With bundling disabled this turns into:
<script type="text/javascript" src="/js/plugins.js" />
<script type="text/javascript" src="/js/jquery.MetaData.js" />
<script type="text/javascript" src="/js/jquery.rating.pack.js.js" />
<script type="text/javascript" src="/js/jquery.dotdotdot-1.5.1.js" />
The files are presented without any additional processing done on them. This is beneficial for development when things like Javascript debugging is necessary.
As of 3.1.9-GA, this also supports producing the 'async' and 'defer' attributes for Javascript files. For instance:
<blc:bundle name="lib.js"
async="true"
defer="true"
mapping-prefix="/js/"
files="plugins.js,
libs/jquery.MetaData.js,
libs/jquery.rating.pack.js,
libs/jquery.dotdotdot-1.5.1.js" />
If bundling is turned on, the single output file contains the 'async' and 'defer' name-only attributes. When bundling is turned off, then those name-only attributes are applied to each individual file reference.
This processor only supports files that end in .js and .css
ResourceBundlingService},
ResourceMinificationService}| Modifier and Type | Field and Description |
|---|---|
protected ResourceBundlingService |
bundlingService |
| Constructor and Description |
|---|
ResourceBundleProcessor() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
getBundleEnabled() |
protected org.thymeleaf.dom.Element |
getElement(String src)
Deprecated.
use
getElement(String, boolean, boolean) instead |
protected org.thymeleaf.dom.Element |
getElement(String src,
boolean async,
boolean defer) |
protected org.thymeleaf.dom.Element |
getLinkElement(String src) |
int |
getPrecedence() |
protected BroadleafResourceHttpRequestHandler |
getRequestHandler(String name,
org.thymeleaf.Arguments arguments) |
protected org.thymeleaf.dom.Element |
getScriptElement(String src)
Deprecated.
use
getScriptElement(String, boolean, boolean) instead |
protected org.thymeleaf.dom.Element |
getScriptElement(String src,
boolean async,
boolean defer) |
protected org.thymeleaf.processor.ProcessorResult |
processElement(org.thymeleaf.Arguments arguments,
org.thymeleaf.dom.Element element) |
doProcess, getMatcherprotected ResourceBundlingService bundlingService
protected boolean getBundleEnabled()
public int getPrecedence()
getPrecedence in class org.thymeleaf.processor.AbstractProcessorprotected org.thymeleaf.processor.ProcessorResult processElement(org.thymeleaf.Arguments arguments,
org.thymeleaf.dom.Element element)
processElement in class org.thymeleaf.processor.element.AbstractElementProcessor@Deprecated protected org.thymeleaf.dom.Element getScriptElement(String src)
getScriptElement(String, boolean, boolean) insteadprotected org.thymeleaf.dom.Element getScriptElement(String src, boolean async, boolean defer)
protected org.thymeleaf.dom.Element getLinkElement(String src)
@Deprecated protected org.thymeleaf.dom.Element getElement(String src)
getElement(String, boolean, boolean) insteadprotected org.thymeleaf.dom.Element getElement(String src, boolean async, boolean defer)
protected BroadleafResourceHttpRequestHandler getRequestHandler(String name, org.thymeleaf.Arguments arguments)
Copyright © 2016. All Rights Reserved.