diff --git a/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java b/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java index 7928b022dfcec..e404fa8a0b7a3 100644 --- a/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java +++ b/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java @@ -674,6 +674,15 @@ static Match validateNestedExpressions(TemplateAnalysis templateAnalysis, ClassI ClassInfo returnType = index.getClassByName(method.returnType().name()); if (returnType != null) { match.setValues(returnType, method.returnType()); + if (root.hasHints()) { + // Root is a property with hint + // E.g. 'it' and 'STATUS' + if (processHints(templateAnalysis, root.asHintInfo().hints, match, index, expression, + generatedIdsToMatches, incorrectExpressions)) { + // In some cases it's necessary to reset the iterator + iterator = parts.iterator(); + } + } } else { // Return type not available return putResult(match, results, expression); diff --git a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/extensions/NamespaceTemplateExtensionTest.java b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/extensions/NamespaceTemplateExtensionTest.java index 4e0525f6f581f..35d7d9212392f 100644 --- a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/extensions/NamespaceTemplateExtensionTest.java +++ b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/extensions/NamespaceTemplateExtensionTest.java @@ -3,10 +3,14 @@ import static io.quarkus.qute.TemplateExtension.ANY; import static org.junit.jupiter.api.Assertions.assertEquals; +import java.util.EnumSet; +import java.util.Set; + import javax.enterprise.event.TransactionPhase; import javax.inject.Inject; import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -20,6 +24,9 @@ public class NamespaceTemplateExtensionTest { @RegisterExtension static final QuarkusUnitTest config = new QuarkusUnitTest() .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) + .addAsResource(new StringAsset( + "{#for state in domain:states}{state.foo}{/for}"), + "templates/foo.html") .addClasses(StringExtensions.class, MyEnum.class, EnumExtensions.class)); @Inject @@ -43,6 +50,8 @@ public void testTemplateExtensions() { engine.parse("{str:quark}").render()); assertEquals("QUARKUS!", engine.parse("{str:quarkus}").render()); + assertEquals("openclosed", + engine.getTemplate("foo").render()); } @TemplateExtension(namespace = "str") @@ -73,9 +82,17 @@ static String quarkAny(String key) { } public enum MyEnum { - ONE, TWO + } + + public enum State { + OPEN, + CLOSED; + + public String getFoo() { + return toString().toLowerCase(); + } } @@ -91,6 +108,11 @@ static TransactionPhase enumValue(String value) { return TransactionPhase.valueOf(value); } + @TemplateExtension(namespace = "domain") + static Set states() { + return EnumSet.allOf(State.class); + } + } }