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

Consider using fragment signatures as a method for passing values to layout templates #157

Closed
ultraq opened this issue Apr 17, 2017 · 1 comment

Comments

@ultraq
Copy link
Owner

ultraq commented Apr 17, 2017

After thinking a bit on #155 and writing it up in the docs, I think it'd be nice to, much like how it's possible in vanilla Thymeleaf, for th:insert/th:replace attribute processors (http://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#parameterizable-fragment-signatures), it'd be nice to be able to pass values from child templates up to their parent layouts in this manner, doing away with the need for th:with attribute processors on the same element (even though I won't remove support for that either, it'll just be another option), eg:

<html layout:decorate="~{your-layout.html(greeting='Hello!'})}">

Parent/layout template:

<html>
  ...
  <p th:text="${greeting}"></p> <!-- You'll end up with "Hello!" in here -->

Some things to think about for whether this is feasible:

  • I'd be unable to enforce parameter correctness for full template references because there's nowhere to specify a signature on a template
  • So parameters used in layout:decorate would require a name
  • Otherwise everything is as expected for layout:insert and layout:replace as they behave just like Thymeleaf's equivalent processors (in fact, I believe these processors already support fragment signatures)
@ultraq
Copy link
Owner Author

ultraq commented Mar 19, 2019

Now available in 2.4.0-SNAPSHOT.

@ultraq ultraq closed this as completed Mar 19, 2019
@ultraq ultraq self-assigned this Mar 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant