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

Merge strategy using conditional blocks around head tags #212

Open
dtrunk90 opened this issue Dec 15, 2020 · 2 comments
Open

Merge strategy using conditional blocks around head tags #212

dtrunk90 opened this issue Dec 15, 2020 · 2 comments
Labels

Comments

@dtrunk90
Copy link

dtrunk90 commented Dec 15, 2020

There seems to be an issue using conditional tags in the layout template:

<head>
    <th:block th:if="${false}">
        <title>test</title>
    </th:block>
</head>

The whole condition will be ignored and the title inside will be processed/rendered.
However this is working:

<head>
    <title th:if="${false}">test</title>
</head>

Tested with version 2.5.1.

@ultraq
Copy link
Owner

ultraq commented Dec 16, 2020

To merge the titles of the layout and content pages, the layout dialect will select the <title> element wherever it is within <head>, and in the process completely bypass any conditions outside of the element, hence why the conditions aren't hit in your first code example but they are hit in your second.

I can't think of a workaround for this at the moment as special processing of <title> is needed so that you only end up with one <title> in the final HTML 🤔

@dtrunk90
Copy link
Author

Well, lets leave it open. In the meantime we can use the second approach as a workaround. Maybe you or I or someone else will have a good idea in the future.

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