Giter Site home page Giter Site logo

thymeleaf-jawr-extension's People

Contributors

dtrunk90 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

thymeleaf-jawr-extension's Issues

Support for icon link tag missing?

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">

jawr.debug.use.random.parameter is not used

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.

NoSuchMethodError: JawrConfig.getJsBundleLinkRenderClass()

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]

Some default values are overriding properties/attributes

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.

Documentation about using with Spring (not Boot) and about Thymeleaf version

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!

Upgrade to jawr 3.9

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

Add configuration attributes

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.

debug mode true and gzip false not working

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

Documentation

Could you provide some examples of how the syntax can be exactly used inside a thymeleaf template.
That would be great :)

TemplateProcessingException when using #jawr.imagePath

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);

SpringBoot with Thymeleaf and JAWR

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 :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.