From 35ecc2f341268be390cc2ec9f3d4e86c138e35ee Mon Sep 17 00:00:00 2001 From: Martin Kouba Date: Mon, 30 Sep 2024 11:59:23 +0200 Subject: [PATCH] Qute: fix reload of templates backed by build item --- .../builditemtemplate/AdditionalTemplatePathTest.java | 5 +++++ .../main/java/io/quarkus/qute/runtime/EngineProducer.java | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/builditemtemplate/AdditionalTemplatePathTest.java b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/builditemtemplate/AdditionalTemplatePathTest.java index 24e4306532a16..989a5fc5ed5ad 100644 --- a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/builditemtemplate/AdditionalTemplatePathTest.java +++ b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/builditemtemplate/AdditionalTemplatePathTest.java @@ -54,6 +54,11 @@ public void testTemplate() { assertEquals("Hello M!", engine.getTemplate("foo/hello.txt").data("name", "M").render()); assertEquals("Hello M!", engine.getTemplate("foo/hello").data("name", "M").render()); assertEquals("And... Hello M!", engine.getTemplate("include").data("name", "M").render()); + + // Test that reload works for additional content-based paths + engine.clearTemplates(); + assertEquals("Hello M!", engine.getTemplate("foo/hello").data("name", "M").render()); + assertEquals("Hello M!", engine.getTemplate("foo/hello.txt").data("name", "M").render()); } } diff --git a/extensions/qute/runtime/src/main/java/io/quarkus/qute/runtime/EngineProducer.java b/extensions/qute/runtime/src/main/java/io/quarkus/qute/runtime/EngineProducer.java index bc3d9c95225df..f6bbc3957396d 100644 --- a/extensions/qute/runtime/src/main/java/io/quarkus/qute/runtime/EngineProducer.java +++ b/extensions/qute/runtime/src/main/java/io/quarkus/qute/runtime/EngineProducer.java @@ -369,7 +369,7 @@ private Optional locate(String path) { // Then try the template contents LOGGER.debugf("Locate template contents for %s", path); String content = templateContents.get(path); - if (path == null) { + if (content == null) { // Try path with suffixes for (String suffix : suffixes) { String pathWithSuffix = path + "." + suffix;