dtrunk90 / thymeleaf-jawr-extension Goto Github PK
View Code? Open in Web Editor NEWThymeleaf JAWR Extension
License: Apache License 2.0
Thymeleaf JAWR Extension
License: Apache License 2.0
tried both of the following, and neither work
<link rel="icon" type="image/x-icon" jawr:href="/images/favicon.ico" />
Gives the following and omits the tag entirely: 2016-03-17 14:35:06,773 WARN AbstractBundleLinkRenderer:102 - No bundle found for path : /images/favicon.ico
<link rel="icon" type="image/x-icon" jawr:src="/images/favicon.ico" />
Renders the tag like so (and the favicon does not work):
<link rel="icon" type="image/x-icon" jawr:src="/images/favicon.ico">
Random parameter is not used in debug mode.
jawr.debug.use.random.parameter is true by default. It does not matter if I set it or not.
I use net.jawr.debug.on=true and in my configuration I mix Facelets and Thymeleaf. Facelets part use random parameter whereas Thymeleaf does not.
java.lang.NoSuchMethodError: net.jawr.web.config.JawrConfig.getJsBundleLinkRenderClass()Ljava/lang/String;
at net.jawr.web.resource.bundle.renderer.RendererFactory.getJsBundleRenderer(RendererFactory.java:46) ~[jawr-core-3.7.jar:na]
at com.github.dtrunk90.thymeleaf.jawr.processor.attr.impl.js.JawrJsElementSubstitutionAttrProcessor.render(JawrJsElementSubstitutionAttrProcessor.java:39) ~[thymeleaf-jawr-extension-1.1.1.jar:na]
at com.github.dtrunk90.thymeleaf.jawr.processor.attr.AbstractJawrElementSubstitutionAttrProcessor.getText(AbstractJawrElementSubstitutionAttrProcessor.java:38) ~[thymeleaf-jawr-extension-1.1.1.jar:na]
at org.thymeleaf.processor.attr.AbstractUnescapedTextChildModifierAttrProcessor.getModifiedChildren(AbstractUnescapedTextChildModifierAttrProcessor.java:60) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.thymeleaf.processor.attr.AbstractChildrenModifierAttrProcessor.processAttribute(AbstractChildrenModifierAttrProcessor.java:59) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.thymeleaf.processor.attr.AbstractAttrProcessor.doProcess(AbstractAttrProcessor.java:87) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.thymeleaf.processor.AbstractProcessor.process(AbstractProcessor.java:212) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.thymeleaf.dom.Node.applyNextProcessor(Node.java:1017) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.thymeleaf.dom.Node.processNode(Node.java:972) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.thymeleaf.dom.Node.processNode(Node.java:990) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
Just recently upgraded, using 2.0.1, JAWR 3.9, thymeleaf 3.0.5, and spring 3.2.1. And after the migration my jawr:useRandomParam="false" lines within my HTML are no longer working. No exceptions are thrown but the random hash is still added after my JS files. Is this something anyone else can reproduce?
I have these settings as follows in my JAWR.properties
jawr.debug.on=true
jawr.debug.use.random.parameter=false
Thanks.
E.g.: https://github.com/ic3fox/jawr-main-repo/blob/master/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/RendererFactory.java#L45 (Added String type parameter)
This needs to be adapted when Jawr 3.9 is released.
Thanks for this great little library.
Please, could you clarify in readme.md
two things that took me a while to discover:
First, when using "plain" Spring (rather than Spring Boot), then declaring the JawrDialect
with Thymeleaf seems to be required, otherwise thymeleaf-jawr-extension
won't process the jawr:
Html attributes:
<bean id="templateEngine" class="org.thymeleaf.spring4.SpringTemplateEngine">
...
<property name="dialects">
<set>
<bean class="org.thymeleaf.spring4.dialect.SpringStandardDialect"></bean>
<bean class="com.github.dtrunk90.thymeleaf.jawr.dialect.JawrDialect" />
</set>
</property>
</bean>
Second, it would be nice to clarify that thymeleaf-jawr-extension
version 2.* works with Thymeleaf 3, whereas thymeleaf-jawr-extension
version 1.* works with Thymeleaf 2.
Thank you!
Add attribute processors for image urls
Hi,
Any plans for new library which supports latest spring boot, spring and thymeleaf versions?
Would you consider releasing this under the Apache v2 license as JAWR is?
See: https://github.com/j-a-w-r/jawr-main-repo/blob/master/LICENSE
Hi there,
with jawr 3.9 I get the following error:
2016-08-24 18:17:33,545 org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/storefront].[dispatcherServlet] [http-nio-127.0.0.1-8112-exec-3] ERROR: Servlet.service() for servlet [dispatcherServlet] in context with path [/storefront] threw exception [Handler processing failed; nested exception is java.lang.NoSuchMethodError: net.jawr.web.resource.bundle.renderer.RendererFactory.getJsBundleRenderer(Lnet/jawr/web/resource/bundle/handler/ResourceBundlesHandler;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lnet/jawr/web/resource/bundle/renderer/JsBundleLinkRenderer;] with root cause
java.lang.NoSuchMethodError: net.jawr.web.resource.bundle.renderer.RendererFactory.getJsBundleRenderer(Lnet/jawr/web/resource/bundle/handler/ResourceBundlesHandler;Ljava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lnet/jawr/web/resource/bundle/renderer/JsBundleLinkRenderer;
at com.github.dtrunk90.thymeleaf.jawr.processor.attr.impl.js.JawrJsElementSubstitutionAttrProcessor.render(JawrJsElementSubstitutionAttrProcessor.java:42)
at com.github.dtrunk90.thymeleaf.jawr.processor.attr.AbstractJawrElementSubstitutionAttrProcessor.getText(AbstractJawrElementSubstitutionAttrProcessor.java:38)
at org.thymeleaf.processor.attr.AbstractUnescapedTextChildModifierAttrProcessor.getModifiedChildren(AbstractUnescapedTextChildModifierAttrProcessor.java:60)
at org.thymeleaf.processor.attr.AbstractChildrenModifierAttrProcessor.processAttribute(AbstractChildrenModifierAttrProcessor.java:59)
And indeed the signature of this method RendererFactory.getJsBundleRenderer
has been changed. Please update to jawr 3.9
It should be possible to configure JAWR elements like the JSP taglib does:
https://jawr.java.net/docs/taglibs.html
useRandomParam
, async
, defer
for <script>
elements and media
, useRandomParam
, alternate
, title
, displayAlternate
for <link>
elements.
In favor of these additional attributes rename jawr:script
to jawr:src
and jawr:style
to jawr:href
.
Hi,
We are using the plugin with spring boot 1.5.1.RELEASE, thymeleaf 3.0.2 release and the latest version of the extension (2.0.1). We have the following problem:
these properties are ignored completely:
jawr:
debug:
on: true
gzip:
on: false
Files are always bundled and gzipped.
We also tried downgraded spring boot to 1.4.0.RELEASE and tyhmeleaf to 3.0.1, just to test the specific feature (debug true) but it din't work either.
Any ideas of what the problem might be?
Thank you
Could you provide some examples of how the syntax can be exactly used inside a thymeleaf template.
That would be great :)
Be able to use expressions as attribute values
http://www.thymeleaf.org/doc/sayhelloagainextendingthymeleafevenmore5minutes.html
Hello,
here's my html:
<span th:with="imgUrl=${#jawr.imagePath('/resources/theme/solarapparel/normal/img/icon-gift.png')}" style="position: absolute; right: 10px; bottom: 10px; width: 60px; height: 60px; background: #ececec url(${imgUrl}) 50% 50% no-repeat; border-radius: 50%;"></span>
and when I try to render the page I get this exception:
org.thymeleaf.exceptions.TemplateProcessingException: Handler "net.jawr.web.resource.bundle.BINARY_CONTEXT_ATTRIBUTE" not present in servlet context. Initialization of Jawr either failed or never occurred. (solar/basic_two_column.html:107)
at com.github.dtrunk90.thymeleaf.jawr.util.ContextUtils.getHandlerFromContext(ContextUtils.java:11)
at com.github.dtrunk90.thymeleaf.jawr.expression.Jawr.imagePath(Jawr.java:23)
at com.github.dtrunk90.thymeleaf.jawr.expression.Jawr.imagePath(Jawr.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.expression.spel.support.ReflectiveMethodExecutor.execute(ReflectiveMethodExecutor.java:113)
at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:102)
at org.springframework.expression.spel.ast.MethodReference.access$000(MethodReference.java:49)
at org.springframework.expression.spel.ast.MethodReference$MethodValueRef.getValue(MethodReference.java:347)
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:88)
at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:120)
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:267)
at org.thymeleaf.spring4.expression.SpelVariableExpressionEvaluator.evaluate(SpelVariableExpressionEvaluator.java:139)
at org.thymeleaf.standard.expression.VariableExpression.executeVariable(VariableExpression.java:154)
at org.thymeleaf.standard.expression.SimpleExpression.executeSimple(SimpleExpression.java:59)
at org.thymeleaf.standard.expression.Expression.execute(Expression.java:103)
at org.thymeleaf.standard.expression.Expression.execute(Expression.java:133)
at org.thymeleaf.standard.expression.Expression.execute(Expression.java:120)
at org.thymeleaf.standard.processor.attr.AbstractStandardLocalVariableDefinitionAttrProcessor.getNewLocalVariables(AbstractStandardLocalVariableDefinitionAttrProcessor.java:89)
at org.thymeleaf.processor.attr.AbstractLocalVariableDefinitionAttrProcessor.processAttribute(AbstractLocalVariableDefinitionAttrProcessor.java:62)
at org.thymeleaf.processor.attr.AbstractAttrProcessor.doProcess(AbstractAttrProcessor.java:87)
at org.thymeleaf.processor.AbstractProcessor.process(AbstractProcessor.java:212)
at org.thymeleaf.dom.Node.applyNextProcessor(Node.java:1017)
at org.thymeleaf.dom.Node.processNode(Node.java:972)
at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
at org.thymeleaf.dom.Node.processNode(Node.java:990)
at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
at org.thymeleaf.dom.Node.processNode(Node.java:990)
at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
at org.thymeleaf.dom.Node.processNode(Node.java:990)
at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
at org.thymeleaf.dom.Node.processNode(Node.java:990)
at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
at org.thymeleaf.dom.Node.processNode(Node.java:990)
at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
at org.thymeleaf.dom.Node.processNode(Node.java:990)
at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
at org.thymeleaf.dom.Node.processNode(Node.java:990)
at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
at org.thymeleaf.dom.Node.processNode(Node.java:990)
at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
at org.thymeleaf.dom.Node.processNode(Node.java:990)
at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
at org.thymeleaf.dom.Node.processNode(Node.java:990)
at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
at org.thymeleaf.dom.Node.processNode(Node.java:990)
at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
at org.thymeleaf.dom.Node.processNode(Node.java:990)
at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
at org.thymeleaf.dom.Node.processNode(Node.java:990)
at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
at org.thymeleaf.dom.Node.processNode(Node.java:990)
at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
at org.thymeleaf.dom.Node.processNode(Node.java:990)
at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
at org.thymeleaf.dom.Node.processNode(Node.java:990)
at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
at org.thymeleaf.dom.Node.processNode(Node.java:990)
at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
at org.thymeleaf.dom.Node.processNode(Node.java:990)
at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
at org.thymeleaf.dom.Node.processNode(Node.java:990)
at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695)
at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668)
at org.thymeleaf.dom.Node.processNode(Node.java:990)
at org.thymeleaf.dom.Document.process(Document.java:93)
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1155)
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1060)
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1011)
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:924)
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:898)
I use this bean:
@Bean(name = { "thymeleafEmailTemplateEngine", "emailTemplateEngine" })
public SpringTemplateEngine thymeleafEmailTemplateEngine(@Qualifier("nemesisDialect") IDialect nemesisDialect) {
final SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.addTemplateResolver(thymeleafSpringResourceTemplateResolver());
templateEngine.addTemplateResolver(thymeleafClasspathTemplateResolver());
templateEngine.addTemplateResolver(thymeleafServletTemplateResolver());
// templateEngine.addTemplateResolver(thymeleafInMemoryTemplateResolver());
Set<IDialect> dialects = new LinkedHashSet<>();
dialects.add(nemesisDialect);
dialects.add(defaultJawrDialect());
templateEngine.setAdditionalDialects(dialects);
return templateEngine;
}
which then I inject and use like this:
getTemplateEngine().process(templateName, ctx);
Do you have any plans to support Thymeleaf 3?
Thank you
Hello,
Could you please have a look at my demo application. I am trying to use the thymeleaf-jawr-extension,
but it does not seem to work.
I use spring boot and my templates and static files reside in /src/main/resources/. Due to deployment to heroku and other cloud services we don't have /src/main/webapp/ anymore. This is also a best practice from the spring boot doc.
Here is my application:
https://github.com/comsysto/spring-boot-js-css-bundle-demo/tree/jawr-question/spring-boot-thymeleaf-jawr
In the templates/angularApp.html I use the following statements:
<link jawr:style="/css/webjars.css" />
<script jawr:script="/js/webjars.js" src="#"></script>
But when Spring Boot starts up there is an exception:
12:27:06.740 [http-nio-8080-exec-1] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: "/css/webjars.css" (angularApp:18)] with root cause
org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: "/css/webjars.css" (angularApp:18)
at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:238) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:79) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:40) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at com.github.dtrunk90.thymeleaf.jawr.AbstractJawrAttrProcessor.getText(AbstractJawrAttrProcessor.java:49) ~[thymeleaf-jawr-extension-1.0.1.jar:na]
at org.thymeleaf.processor.attr.AbstractUnescapedTextChildModifierAttrProcessor.getModifiedChildren(AbstractUnescapedTextChildModifierAttrProcessor.java:60) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at org.thymeleaf.processor.attr.AbstractChildrenModifierAttrProcessor.processAttribute(AbstractChildrenModifierAttrProcessor.java:59) ~[thymeleaf-2.1.4.RELEASE.jar:2.1.4.RELEASE]
at com.github.dtrunk90.thymeleaf.jawr.JawrTagRemovingAttrProcessor.processAttribute(JawrTagRemovingAttrProcessor.java:34) ~[thymeleaf-jawr-extension-1.0.1.jar:na]
I added the Dialect to the template Engine in: WebAppConfig.java
But something is not right. There are also the JAWR Spring Controllers here: webapp/jawr
Could you please tell me what I am doing wrong. Thanks in advance :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.