From d61cf55f37207c07dd3646ebceb9361733b71c38 Mon Sep 17 00:00:00 2001 From: Marcos Pereira Date: Wed, 8 Nov 2023 09:06:39 -0500 Subject: [PATCH] Update jte to version 3.1.4 (#617) --- gradle/libs.versions.toml | 2 +- src/main/docs/guide/views/templates/jte.adoc | 9 ++++----- test-suite-graal/test-suite-graal-jte/build.gradle | 1 - .../views/jte/JteViewsRendererConfiguration.java | 3 ++- .../micronaut/views/jte/PlainJteViewsRenderer.java | 14 +++++++++----- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 785280e92..d131e6f34 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -16,7 +16,7 @@ spock = "2.3-groovy-4.0" managed-freemarker = "2.3.32" managed-handlebars = "4.3.1" managed-jstachio = "1.3.3" -managed-jte = "2.3.2" +managed-jte = "3.1.4" managed-rocker = "1.4.0" managed-soy = "2023-09-13" managed-thymeleaf = "3.1.2.RELEASE" diff --git a/src/main/docs/guide/views/templates/jte.adoc b/src/main/docs/guide/views/templates/jte.adoc index 5622d6373..909202333 100644 --- a/src/main/docs/guide/views/templates/jte.adoc +++ b/src/main/docs/guide/views/templates/jte.adoc @@ -1,5 +1,5 @@ -Micronaut Views Jte includes api:views.jte.JteViewsRenderer[] which uses -the https://jte.gg[Jte] Java-based template engine. +Micronaut Views Jte includes api:views.jte.JteViewsRenderer[] which uses https://jte.gg[jte] (**J**ava **T**emplate **E**ngine), a +secure and lightweight template engine for Java and Kotlin. Add the `micronaut-views-jte` dependency to your classpath. @@ -15,11 +15,11 @@ include::{testsviewsJte}/resources/views/home.jte[] === Compiling Templates -Jte templates may be precompiled at build time. This can be done by a https://github.com/casid/jte/blob/master/DOCUMENTATION.md#gradle[Gradle plugin] or https://github.com/casid/jte/blob/master/DOCUMENTATION.md#maven[Maven plugin]. If not precompiled, the application will need a JDK so it can compile templates at runtime. +Jte templates may be precompiled at build time. This can be done by a https://jte.gg/pre-compiling/#gradle[Gradle plugin] or https://jte.gg/pre-compiling/#maven[Maven plugin]. If not precompiled, the application will need a JDK so it can compile templates at runtime. === Dynamic Reloading -When 'dynamic' is enabled (see below), JTE will load templates from the project source directory, and will reload them after changes. +When `dynamic` is enabled (see below), jte will load templates from the project source directory, and will reload them after changes. === Configuration @@ -29,7 +29,6 @@ include::{includedir}configurationProperties/io.micronaut.views.jte.JteViewsRend == .kte (Kotlin) templates - To use `.kte` (Kotlin) templates include the dependency:. dependency:jte-kotlin[groupId="gg.jte"] diff --git a/test-suite-graal/test-suite-graal-jte/build.gradle b/test-suite-graal/test-suite-graal-jte/build.gradle index a57d07603..65702686f 100644 --- a/test-suite-graal/test-suite-graal-jte/build.gradle +++ b/test-suite-graal/test-suite-graal-jte/build.gradle @@ -11,7 +11,6 @@ dependencies { jte { sourceDirectory = file('src/main/resources/views').toPath() generate() - generateNativeImageResources = false } tasks.getByName("inspectRuntimeClasspath") { diff --git a/views-jte/src/main/java/io/micronaut/views/jte/JteViewsRendererConfiguration.java b/views-jte/src/main/java/io/micronaut/views/jte/JteViewsRendererConfiguration.java index 0b26fb9aa..b30352459 100644 --- a/views-jte/src/main/java/io/micronaut/views/jte/JteViewsRendererConfiguration.java +++ b/views-jte/src/main/java/io/micronaut/views/jte/JteViewsRendererConfiguration.java @@ -42,7 +42,8 @@ public interface JteViewsRendererConfiguration { String getDynamicSourcePath(); /** - * When using dynamic templates, build them with binary content (see https://github.com/casid/jte/blob/master/DOCUMENTATION.md#binary-rendering-for-max-throughput). + * When using dynamic templates, build them with binary content + * (see jte Binary Rendering docs). * (When using precompiled templates, this setting is determined by the build configuration.) * @return true to enable building binary content */ diff --git a/views-jte/src/main/java/io/micronaut/views/jte/PlainJteViewsRenderer.java b/views-jte/src/main/java/io/micronaut/views/jte/PlainJteViewsRenderer.java index 63419eef7..109525751 100644 --- a/views-jte/src/main/java/io/micronaut/views/jte/PlainJteViewsRenderer.java +++ b/views-jte/src/main/java/io/micronaut/views/jte/PlainJteViewsRenderer.java @@ -27,7 +27,6 @@ import io.micronaut.views.ViewsConfiguration; import jakarta.inject.Singleton; -import java.io.Writer; import java.nio.file.Paths; /** @@ -66,8 +65,8 @@ public PlainHtmlTemplateOutput(TemplateOutput delegate) { } @Override - public Writer getWriter() { - return delegate.getWriter(); + public void setContext(String tagName, String attributeName) { + // no-op } @Override @@ -76,8 +75,8 @@ public void writeContent(String value) { } @Override - public void setContext(String tagName, String attributeName) { - // no-op + public void writeContent(String value, int beginIndex, int endIndex) { + delegate.writeContent(value, beginIndex, endIndex); } @Override @@ -154,5 +153,10 @@ public void writeUserContent(Number value) { public void writeUserContent(Character value) { delegate.writeUserContent(value); } + + @Override + public void writeUnsafeContent(String value) { + delegate.writeUnsafeContent(value); + } } }