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

Added support for multiple fragments definition #166

Merged
merged 4 commits into from
Jan 31, 2018
Merged

Conversation

Vineg
Copy link

@Vineg Vineg commented Dec 21, 2017

I've separated processor names to avoid ambiguity for cases with nesting. To retain backward compatibility I left "fragment" processor and created separate "define" and "collect" processors.

Created different processor names for source and target elements: define
and collect
@ultraq
Copy link
Owner

ultraq commented Dec 22, 2017

Hi @Vineg, thanks for the PR!

Firstly though, could you explain to me what a "collect processor" is for? I'd like to understand the use case and reasoning behind the processor so I can determine where it fits into the overall layout dialect. I can gather a few details from what you've written in this PR and in your code, but it'd help me to see/read it explained to me too.

@Vineg
Copy link
Author

Vineg commented Dec 23, 2017

My use case is simple. I have popups in the end of the Common.html body template. Then I define some popups in Layout.html and some more in Content.html. I want them all to appear in the end. I probably could do this with current "fragment" processor, but it would be quite inconvenient

Another use case would be collecting head contents among children, but you already implemented it explicitly

@Vineg
Copy link
Author

Vineg commented Dec 28, 2017

@ultraq just added one more test case we really missing in our project

@ultraq
Copy link
Owner

ultraq commented Jan 31, 2018

Sorry for taking so long on getting back to you with this PR! (I've been on holiday.)

I especially like what you've done with accumulating the fragments, and I've been thinking about turning that into the standard behaviour for how fragments are found. But then when it comes to deciding which fragments to use, maybe make it configurable by the dev to either take the first with the same name (current behaviour of decorate) or to append them all together (behaviour of your new collect processor), similar to how the <head> merging is configurable.

Anyway, that's just an idea I have and probably won't implement for a long time. Until then I'll merge this PR and create a 2.3.0-SNAPSHOT release with this included in it. I'll get around to writing some docs for it too once I can see how to fit it in with the other stuff.

If you'd like to be added to the <contributors> section of the generated pom.xml file (example: /~https://github.com/ultraq/thymeleaf-layout-dialect/blob/master/build.gradle#L37-L49), let me know with a comment on this PR and I'll add as many or as few details as you're willing to share. Details of what can go into the <contributors> section can be found here: https://maven.apache.org/pom.html#Contributors

TODO:

  • Create 2.3.0-SNAPSHOT w/ this PR
  • Write docs on new layout:collect processor

@ultraq ultraq merged commit 3a7f79e into ultraq:master Jan 31, 2018
@ultraq ultraq added this to the Layout Dialect 2.3 milestone Feb 11, 2018
@ultraq ultraq mentioned this pull request Jul 10, 2021
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants