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

Pass object with include #12

Closed
jhcao23 opened this issue Feb 5, 2013 · 5 comments
Closed

Pass object with include #12

jhcao23 opened this issue Feb 5, 2013 · 5 comments
Labels

Comments

@jhcao23
Copy link

jhcao23 commented Feb 5, 2013

[Enhancement]
The layout:include feature is pretty like JSF facelet way!
In real JSF, we can pass String or objects or even collection to the facelet,
can this layout:include pass object(s) to the included fragment e.g. modal div?

@ultraq
Copy link
Owner

ultraq commented Feb 5, 2013

Yes, in a way. layout:include doesn't do any object passing itself, but once it includes the fragment/template you chose, any objects defined using Thymeleaf's th:with or th:object attributes (or even the iteration variables created in a th:each loop) will be visible to that fragment when it gets processed.

Using a shortened example from the readme:

<div layout:include="Modal2.html :: modal" th:with="modalId='message'>
</div>

The modalId object is a string that will be visible to the Modal2.html :: modal fragment. That object can be anything, including collections.

@jhcao23
Copy link
Author

jhcao23 commented Feb 6, 2013

It is a wonderful feature which make the template perfect - so we can get rid of tiles or facelet any more!
Is that possible to add this plugin into next official release of thymeleaf?

@ultraq
Copy link
Owner

ultraq commented Feb 7, 2013

I'm glad you've found my Thymeleaf dialect useful :) It won't be part of an official release though as it doesn't feel like 'core' functionality - just like how SiteMesh wasn't a core part of JSP, and how Facelets isn't a core part of JSF, but people would use SiteMesh/Facelets anyway because they give you very powerful templating options.

@ultraq ultraq closed this as completed Feb 7, 2013
@jgrtalk
Copy link

jgrtalk commented Sep 19, 2014

I can't process recursively my fragments.

I've only one level processed.

Any help?

Here is my Java bean :
class Tag {
private String code;
private List children;
// getter
// setter
}

I have 2 templates :
/templates/main.html

/templates/recursive.html

My result :

  • TAG11
  • TAG12

Expected :

  • TAG11
  • TAG12
    • TAG121
    • TAG122

I'm using latest versions of Thymeleaf + layout

@ultraq
Copy link
Owner

ultraq commented Sep 20, 2014

Hey @jgrtalk, that looks like a general Thymeleaf question, unreleated to this GitHub issue. Could you instead post your question to our forums, http://forum.thymeleaf.org/General-Usage-f2234430.html, where we can better answer it.

Repository owner locked and limited conversation to collaborators Sep 20, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants