From 920f490d609f0ceaee458c13f3d31a29b0216e57 Mon Sep 17 00:00:00 2001 From: J Lannoy Date: Fri, 10 Jul 2020 22:56:31 +0200 Subject: [PATCH 1/2] Implement nested content for user-defined tags --- docs/src/main/asciidoc/qute-reference.adoc | 7 ++- .../io/quarkus/qute/UserTagSectionHelper.java | 23 +++++++++- .../java/io/quarkus/qute/UserTagTest.java | 45 +++++++++++++++++++ 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/docs/src/main/asciidoc/qute-reference.adoc b/docs/src/main/asciidoc/qute-reference.adoc index 99f3b323778f0..e05cb9d985ee2 100644 --- a/docs/src/main/asciidoc/qute-reference.adoc +++ b/docs/src/main/asciidoc/qute-reference.adoc @@ -633,10 +633,12 @@ Let's suppose we have a template called `itemDetail.html`: ---- {#if showImage} <1> {it.image} <2> + {nested} <3> {/if} ---- <1> `showImage` is a named parameter. <2> `it` is a special key that is replaced with the first unnamed param of the tag. +<3> (optional) `nested` is a special key that will be replaced by the content of the tag. Now if we register this template under the name `itemDetail.html` and if we add a `UserTagSectionHelper` to the engine: @@ -656,12 +658,15 @@ We can include the tag like this: ---- <1> `item` is resolved to an iteration element and can be referenced using the `it` key in the tag template. +<2> Tag content injected using the `nested` key in the tag template. === Engine Configuration diff --git a/independent-projects/qute/core/src/main/java/io/quarkus/qute/UserTagSectionHelper.java b/independent-projects/qute/core/src/main/java/io/quarkus/qute/UserTagSectionHelper.java index 670c779140be0..f3ea81a2f5f5b 100644 --- a/independent-projects/qute/core/src/main/java/io/quarkus/qute/UserTagSectionHelper.java +++ b/independent-projects/qute/core/src/main/java/io/quarkus/qute/UserTagSectionHelper.java @@ -13,6 +13,8 @@ public class UserTagSectionHelper implements SectionHelper { private static final String IT = "it"; + private static final String NESTED = "nested"; + private final Supplier