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

Passing HTML into nested fragments doesn't work #57

Closed
oniekrenz opened this issue Oct 25, 2014 · 2 comments
Closed

Passing HTML into nested fragments doesn't work #57

oniekrenz opened this issue Oct 25, 2014 · 2 comments
Labels

Comments

@oniekrenz
Copy link
Contributor

I wanted to use the following structure but it doesn't work.

test.html

<th:block layout:fragment="a">
    <div layout:include="test::b">
        <div layout:fragment="b-content">
            <th:block layout:fragment="a-content"/><!-- doesn't work -->
        </div>
    </div>
    <th:block layout:fragment="a-content"/><!-- works -->
</th:block>

<th:block layout:fragment="b">
    <th:block layout:fragment="b-content"/>
</th:block>

template.html

<div layout:include="test::a">
    <th:block layout:fragment="a-content">A content</th:block>
</div>

It seems to me that the nested fragment reference 'a-content' can't be interpreted as such. Instead it it interpreted as setting a 'a-content' fragment parameter for fragment b. This is caused by the ambiguity of the 'layout:fragment' attribute which serves for both purposes.
Instead another 'layout:fragmentref' attribute could help but this would ruin all existing scripts.

@oniekrenz
Copy link
Contributor Author

I think I found a solution.
AbstractContentProcessor.findFragments:85 proceeds to recurse even if a fragmentname has been found, which IMHO does not make sense. Recursing should only be done when fragmentname is null which can be achieved by adding an else branch to the first if statement:

} else if (!hasAttribute(element, DIALECT_PREFIX_LAYOUT, PROCESSOR_NAME_INCLUDE) &&

oniekrenz added a commit to oniekrenz/thymeleaf-layout-dialect that referenced this issue Nov 13, 2014
@oniekrenz oniekrenz mentioned this issue Nov 13, 2014
@ultraq
Copy link
Owner

ultraq commented Nov 14, 2014

Closing - conversation continued in linked PR.

@ultraq ultraq closed this as completed Nov 14, 2014
@ultraq ultraq added the bug label Nov 14, 2014
ultraq added a commit that referenced this issue Nov 17, 2014
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