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

Problems with template mode LEGACYHTML5 #23

Closed
krat0s opened this issue Jun 24, 2013 · 8 comments
Closed

Problems with template mode LEGACYHTML5 #23

krat0s opened this issue Jun 24, 2013 · 8 comments
Assignees
Labels

Comments

@krat0s
Copy link

krat0s commented Jun 24, 2013

When changing the template mode from HTML5 to LEGACYHTML5 I keep getting the following exception:

[nz.net.ultraq.thymeleaf.decorator.DecoratorProcessor] layout:decorator attribute must appear in the root element of your content page

In my content page, the layout:decorator attribute does appear in the root element and the page is processed correctly as long as the template mode is set to HTML5. I have tried to debug the source code and it seems that

if (!(element.getParent() instanceof Document))

is always true as the parent is never the document but rather the enclosing element (in my case <body>).

The reason I need to use LEGACYHTML5 is that I need to use the th:utext attribute to include text which may contain HTML formatting, which is not necessarily XML-formed (i.e. it contains elements like <br> without a closing tag).

Is the layout dialect incompatible with the LEGACYHTML5 mode or am I missing something?

@ghost ghost assigned ultraq Jun 24, 2013
@ultraq
Copy link
Owner

ultraq commented Jun 24, 2013

I don't think you're missing anything there, and I'll admit I haven't tested (and don't have any tests) for the LEGACYHTML5 template mode, so you've likely stumbled across something I didn't know about.

I'll try to replicate the problem (a content page that ends-up in the <body> element right?) and get back to you on this.

@ultraq
Copy link
Owner

ultraq commented Jun 30, 2013

I've found out that NekoHTML is responsible for adding <html> and <body> elements when processing template fragments in LEGACYHTML5 mode, making the restriction that throws the exception fail in your case. Since I can't do anything about the Neko parser, I've tried relaxing the restriction when using LEGACYHTML5 mode.

Do you use Maven? If so, I've uploaded a version 1.1.2-SNAPSHOT of the Layout Dialect that includes this fix. Can you test that out and see if it works for you? If you don't use Maven, let me know and I'll find a place to upload a ZIP of that snapshot version for you to download.

@krat0s
Copy link
Author

krat0s commented Jul 3, 2013

Thank you for looking into it and providing a fix. I do use Maven. I'll test it as soon as I can and I'll get back to you.

@ultraq
Copy link
Owner

ultraq commented Jul 29, 2013

Did you manage to get this one tested?

@krat0s
Copy link
Author

krat0s commented Jul 30, 2013

Sorry for not getting back to you earlier as I've been working on a different project. The snapshot doesn't seem to be available in the maven repository. Can you double check? Alternatively, you can also send me the link where I can download the JAR (I've tried the link on https://github.com/ultraq/thymeleaf-layout-dialect/tree/dev but it's not working either). Thanks!

@ultraq
Copy link
Owner

ultraq commented Jul 30, 2013

I probably uploaded to the wrong repository. I sent it to this one here: https://oss.sonatype.org/content/repositories/snapshots/
If you can't configure your project to use that repository, then there's a snapshot JAR in the above repository that you can download, link: https://oss.sonatype.org/content/repositories/snapshots/nz/net/ultraq/thymeleaf/thymeleaf-layout-dialect/1.1.2-SNAPSHOT/thymeleaf-layout-dialect-1.1.2-20130630.084617-1.jar

@krat0s
Copy link
Author

krat0s commented Jul 31, 2013

Thank you for the link. I just did a couple of tests and at first glance it seems to work fine. Well done! What side effects do you think there could be? Anything in particular I should pay attention to? I suppose the original check was put there for a reason. Thank you again for the quick fix!

@ultraq
Copy link
Owner

ultraq commented Jul 31, 2013

If there is any side effect, it's that developers can now put layout:decorator anywhere in their pages when using the LEGACYHTML5 mode. If they do though, then the results can be really unpredictable.

So long as everyone follows the instructions in the readme, they should be fine. If they don't, then I can't be held responsible for what might happen :)

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

No branches or pull requests

2 participants