Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Thymeleaf 3.0 #68

Closed
19 tasks done
ultraq opened this issue Apr 14, 2015 · 39 comments
Closed
19 tasks done

Support for Thymeleaf 3.0 #68

ultraq opened this issue Apr 14, 2015 · 39 comments

Comments

@ultraq
Copy link
Owner

ultraq commented Apr 14, 2015

Thymeleaf 3.0, currently under heavy development, will change the API for dialects. I'd also like to get the layout dialect ready for Thymeleaf 3.0 to help with the beta cycle I imagine it will go through (I think some will want to test the new Thymeleaf alongside this dialect - I know I will).


Thymeleaf 3.0 is now approaching a 3.0 release. I've been doing a lot to update the layout dialect, but I'm finding some difficulty wrapping my head around the new architecture. To help myself out, I'm approaching the problem a feature at a time (and racking-up TODOs along the way) as per the checklist below. It should also give some kind of transparency of my progress.

Features with a date to the right of them indicate that they are part of a 2.0.0-SNAPSHOT version uploaded on that day.

  • Compiles against Thymeleaf 3.0 (SNAPSHOT after BETA03) 7 May
  • Compiles against Thymeleaf 3.0 (RELEASE) 10 May
  • HTML document decoration (layout:decorator) 16 May
    • DOCTYPE merging 22 June
    • <head> element decoration 16 May
      • <title> replacement (use child title over parent title) 20 May
      • <title> pattern processing (layout:title-pattern) 18 June
      • Appending element sorting strategy 16 May
      • Grouping element sorting strategy 18 May
    • <body> element decoration 15 May
  • XML document decoration (layout:decorator) 7 May
    • element decoration 7 May
    • attribute value merging (including the 1.4.0 changes for th:with) 7 May
    • copying directives found outside of the root element 20 June
  • Fragment inclusion 4 June
    • via layout:include 30 May
    • via layout:replace 31 May
    • via layout:insert (new in Thymeleaf 3.0) 4 June
    • support for fragment parameters 16 June

This work is also part of the Layout Dialect 2.0 milestone that includes a lot of other issues that I want to do for this next release.

2.0.0-SNAPSHOTs will be uploaded at least as often as whenever one of the attribute processors is complete. This should let developers who may only use that feature test what is currently there.

Feature completion list last updated 22 June 2016

@ultraq ultraq self-assigned this Apr 14, 2015
@ultraq ultraq added this to the Thymeleaf Layout Dialect 2.0 milestone Apr 14, 2015
@ultraq ultraq changed the title Make the Layout Dialect compatible with Thymeleaf 3.0 Support for Thymeleaf 3.0 Apr 14, 2015
@ultraq
Copy link
Owner Author

ultraq commented Sep 26, 2015

In-flight "docs" for the new dialect API: thymeleaf/thymeleaf#401

@ebussieres
Copy link

Is there an ETA for layout dialect to work with thymeleaf 3.0 ? I would like to try thymeleaf 3 alpha with layout dialect.

@ultraq
Copy link
Owner Author

ultraq commented Oct 28, 2015

I'm actually waiting for a beta version to start dev work - the API just kept changing during the alpha! That should be soon now though if talk on the Thymeleaf GitHub is anything to go by (eg: thymeleaf/thymeleaf#380 (comment))

@ebussieres
Copy link

All right thank you for your quick response :)

@marcosbis
Copy link

Hi there,
Have you got any updates about Layout Dialect supporting the new thymeleaf 3.0, I think beta01 version was released last week.

Thanks!

@ultraq
Copy link
Owner Author

ultraq commented Nov 3, 2015

It'll still be a while - I only just created a new code branch for 3.0 development and updated the build to download the 3.0 beta.

@Fornori
Copy link

Fornori commented Dec 1, 2015

Hello. Any news about support 3.0Beta1?

@robertobsc
Copy link

Hello @ultraq ! Looking foward to your dialect support for 3.0 beta!

@beradrian
Copy link

+1

@michaelhaessig
Copy link

Are there any news on the update progress ?

@ultraq
Copy link
Owner Author

ultraq commented Jan 24, 2016

Hey peeps, still nothing. I've only managed to update my other dialects to have snapshots with the 3.0 beta as an exercise to become more familiar with how Thymeleaf 3.0 does things. The architecture is quite different, and a lot of what I did in Thymeleaf 2.x I can't do here, so I'm having to come up with new ways of doing things.

@ultraq
Copy link
Owner Author

ultraq commented Jan 24, 2016

For future reference, any progress (or lack thereof), can be found in the thymeleaf-3.0 branch of this project.

@xaph
Copy link

xaph commented Feb 19, 2016

hi @ultraq thanks for dev branch but maven can't resolve 2.0.0-SNAPSHOT version.

Do you have any plan on releasing new version?

@eddumelendez
Copy link

I am working in the integration with spring-boot spring-projects/spring-boot#4393 and we will need it.

@yvanavermaet
Copy link

Any update? If you need a hand with functional testing, I'd be happy to help.

@ptahchiev
Copy link

+1

@ultraq
Copy link
Owner Author

ultraq commented May 7, 2016

First 2.0.0-SNAPSHOT uploaded with only the few features checked on the list I've added to the original post.

Basically, only XML document decoration which doesn't include having to copy directives (eg: DOCTYPEs or comments) outside of the root elements, eg: this test file: https://github.com/ultraq/thymeleaf-layout-dialect/blob/thymeleaf-3.0/Tests/nz/net/ultraq/thymeleaf/tests/decorators/xml/Document-XmlDecoration.thtest

@linux-china
Copy link

+1

@tobiasflohre
Copy link

+1

@ultraq
Copy link
Owner Author

ultraq commented May 16, 2016

Just an FYI to anybody watching: the latest 2.0.0-SNAPSHOT now has as many features in it as the original version 1.0 of the layout dialect, so it may be useful to someone out there to play around with.

@rakpan
Copy link

rakpan commented May 17, 2016

+1

@robvanderboom
Copy link

Hi,
how can i already use 2.0.0.-SNAPSHOT in pom.xml ?
have dependency (see below) but it doesn'nt work.
Is there other way i can already use the snapshot ?

nz.net.ultraq.thymeleaf thymeleaf-layout-dialect 2.0.0-SNAPSHOT

@ultraq
Copy link
Owner Author

ultraq commented May 20, 2016

@robvanderboom, you can follow the instructions in this section here to enable access to the snapshot repositories: http://www.thymeleaf.org/faq.html#use-snapshot

@robvanderboom
Copy link

robvanderboom commented May 22, 2016

Thanks a lot, yes this is ok now.
However (i am employee and upgrading from 2->3) i get an exception every time i use a "/" :

... etc.

If i place 2col_wide_left one level up and define it as "2col_wide_left" it goes ok.
But then on other places like "data:addurl="${/add-interest}" it failes with exact same exception. It 'looks' like everywhere i use the slash it sees is as a wrong expression....
Don't know if concerns the layout-dialect snapshot, don't think so, but also don't know were to report this bug, since nothing to find about this issue. And it is a project that i only upgrade to newer version and did all code changes suggested in Thymeleaf 3 manual.

org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: "layout/2col_wide_left" (template: "page/login" - line 2, col 11)
org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:131)
org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:62)
org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:44)
org.thymeleaf.standard.expression.IStandardExpressionParser$parseExpression.call(Unknown Source)
nz.net.ultraq.thymeleaf.expressions.ExpressionProcessor.process(ExpressionProcessor.groovy:52)
nz.net.ultraq.thymeleaf.expressions.ExpressionProcessor$process.call(Unknown Source)
nz.net.ultraq.thymeleaf.decorators.DecoratorProcessor.doProcess(DecoratorProcessor.groovy:87)
org.thymeleaf.processor.element.AbstractAttributeModelProcessor.doProcess(AbstractAttributeModelProcessor.java:76)
org.thymeleaf.processor.element.AbstractElementModelProcessor.process(AbstractElementModelProcessor.java:98)
org.thymeleaf.util.ProcessorConfigurationUtils$ElementModelProcessorWrapper.process(ProcessorConfigurationUtils.java:649)
org.thymeleaf.engine.ProcessorTemplateHandler.handleOpenElement(ProcessorTemplateHandler.java:1499)

@tobiasflohre
Copy link

@robvanderboom I also stumbled over this exception. It seems that from Thymeleaf 3 you have to put literals between single quotes, otherwise it is treated as an expression. So try
layout:decorator="'layout/2col_wide_left'"
instead of
layout:decorator="layout/2col_wide_left"

@ultraq
Copy link
Owner Author

ultraq commented May 22, 2016

@robvanderboom, @tobiasflohre's suggestion seems legit, but this speaks to me of maybe some undesired behaviour from the expression engine if it suddenly can't interpret fragment paths with a / in them. Has an issue been raised against the Thymeleaf project for that change in behaviour?

Also, with the 2.0.0-SNAPSHOT versions, I've tried interpreting the value that goes into layout:decorator as an expression (in 1.x it was treated as a straight out string), but if it has this effect, then I might change that back in a future snapshot...

@robvanderboom
Copy link

The additional single quote helps for layout:decorator, but seems have to do this also for attributes like data:addurl="@{/add-interest}". Try to do all and see whats happining. But seems indeed that the expression engine is doing something strange and this isn't the final solution... Keep you updated...

@robvanderboom
Copy link

robvanderboom commented May 22, 2016

don't know were to start with this issue. It seems there is something new in Thymeleaf three that wants to see everything as an expression :->
For example i have a template with a <span data:title="${article.title}"></span>
It then gives an exception org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: "example title". So this means it first translates its to the correct article's title and then again wants to parse this result as an expression.... So first i thought it was only with the "/" but now it looks like there is a second layer parsing everything again ....

@ultraq
Copy link
Owner Author

ultraq commented May 23, 2016

That last bit about the data:title you might need to bring up with the makers of the data attribute dialect (https://github.com/mxab/thymeleaf-extras-data-attribute).

@tobiasflohre
Copy link

@ultraq I'm checking the Snapshot implementation currently, and I found out that the template which is used to decorate (surround) our main template is loaded four times:

  • one time completely at DecoratorProcessor 92
  • one time with selector head at HtmlDocumentDecorator 72
  • one time with selector body at HtmlDocumentDecorator 101
  • one time with selector html at HtmlDocumentDecorator 119

Do you think that's necessary? Couldn't you clone the one loaded the first time? We have remote access for the template, so we have a little performance issue with that.

@ultraq
Copy link
Owner Author

ultraq commented May 23, 2016

Hi @tobiasflohre, could you please raise a separate issue for that? I'm starting to think this one might get swamped if we try to track everything in the snapshot against it.

@tobiasflohre
Copy link

Yes, that's better. Here it is: #108

@robvanderboom
Copy link

robvanderboom commented May 30, 2016

My upgrade to 3.0 does go without issues, one is solved now in the thymeleaf attribute extra lib (version 2.0.1). Now in my current project the contents disappears because of the layout:decorator. Below a part of the code that is working in version thymeleaf 2 ?
WHen i remove the layout:decorator my is in the result of the page.
But with the layout:decorator the result is ... so empty...
Is Thymeleaf 3 more strict, and if so, where do i find this specs...

Tried a lot of thinks but content is always empty with the decorator...
I use version 2.0-snapshot of the dialect layout.

PS: even when the template 2col_wide_left is empty (or whatever is placed in it), the head-content is not showing up anymore, and without it it is ....

!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorator="'layout/2col_wide_left'">
    <head>
        <title>Title</title>
        [everything i put here like a href to load css is removed from the result ]
    </head>
    <body>
.... etc.

@robvanderboom
Copy link

And as addon to above: is this the right place for my problem or should i crreate a new issue for this ? In my opinion it is a Or a bug Or a missing migration step in the "3 minutes guides". This sinces the migration guides steps are all followed and it is working in thymeleaf 2 (this construction is used througout the production website). So if it is not a bug of the layout dialect lib, it should explain why this part is not working anymore after migration (so what do i have to change ??) in the migration part.

@ultraq
Copy link
Owner Author

ultraq commented May 31, 2016

Hi @robvanderboom, I was just about to ask that you open another issue for this, so please do 😃

@robvanderboom
Copy link

Thanks @ultraq, i did: #111

@bkontur
Copy link

bkontur commented Jun 6, 2016

when this new-release-for-thymeleaf-3 will be released ?
thx

@ptahchiev
Copy link

It would be nice to have this in spring-boot 1.4 (which is scheduled to come some time around 20th of June). And I know for sure the spring-boot team is depending on this layout dialect.

spring-projects/spring-boot#4393

@ultraq
Copy link
Owner Author

ultraq commented Jun 22, 2016

The 2.0 snapshot now has feature parity with the latest of the 1.x branch! 😀

There's still a bit of work to be done, namely: a few edge case tests that I've accumulated during the 1.x lifetime (some devs using the layout dialect in ways I never thought of!), bugs/regressions that people have brought forward during their testing of the 2.0 snapshots, and a decent amount of documentation to update. Some of these are associated with the 2.0 milestone, so anybody curious about those can check the milestone.

Almost there!

turtle climbing fence

@ultraq ultraq closed this as completed Jun 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests