@ -210,13 +210,8 @@ The following table shows the templating libraries that we have tested on differ
@@ -210,13 +210,8 @@ The following table shows the templating libraries that we have tested on differ
TIP: The basic rule for integrating any other script engine is that it must implement the
@ -228,17 +223,8 @@ TIP: The basic rule for integrating any other script engine is that it must impl
@@ -228,17 +223,8 @@ TIP: The basic rule for integrating any other script engine is that it must impl
You need to have the script engine on your classpath, the details of which vary by script engine:
* The https://openjdk.java.net/projects/nashorn/[Nashorn] JavaScript engine is provided with
Java 8+. Using the latest update release available is highly recommended.
* https://www.jruby.org[JRuby] should be added as a dependency for Ruby support.
* https://www.jython.org[Jython] should be added as a dependency for Python support.
* `org.jetbrains.kotlin:kotlin-script-util` dependency and a `META-INF/services/javax.script.ScriptEngineFactory`
file containing a `org.jetbrains.kotlin.script.jsr223.KotlinJsr223JvmLocalScriptEngineFactory`
line should be added for Kotlin script support. See
https://github.com/sdeleuze/kotlin-script-templating[this example] for more detail.
You need to have the script templating library. One way to do that for JavaScript is
through https://www.webjars.org/[WebJars].
[[webflux-view-script-integrate]]
=== Script Templates
@ -246,7 +232,7 @@ through https://www.webjars.org/[WebJars].
@@ -246,7 +232,7 @@ through https://www.webjars.org/[WebJars].
You can declare a `ScriptTemplateConfigurer` bean to specify the script engine to use,
the script files to load, what function to call to render templates, and so on.
The following example uses Mustache templates and the Nashorn JavaScript engine:
The following example uses the Jython Python engine:
fun configurer() = ScriptTemplateConfigurer().apply {
engineName = "nashorn"
setScripts("mustache.js")
renderObject = "Mustache"
engineName = "jython"
setScripts("render.py")
renderFunction = "render"
}
}
@ -305,94 +287,7 @@ The `render` function is called with the following parameters:
@@ -305,94 +287,7 @@ The `render` function is called with the following parameters:
TIP: The basic rule for integrating any other script engine is that it must implement the
@ -30,18 +25,8 @@ TIP: The basic rule for integrating any other script engine is that it must impl
@@ -30,18 +25,8 @@ TIP: The basic rule for integrating any other script engine is that it must impl
You need to have the script engine on your classpath, the details of which vary by script engine:
* The https://openjdk.java.net/projects/nashorn/[Nashorn] JavaScript engine is provided with
Java 8+. Using the latest update release available is highly recommended.
* https://www.jruby.org[JRuby] should be added as a dependency for Ruby support.
* https://www.jython.org[Jython] should be added as a dependency for Python support.
* `org.jetbrains.kotlin:kotlin-script-util` dependency and a `META-INF/services/javax.script.ScriptEngineFactory`
file containing a `org.jetbrains.kotlin.script.jsr223.KotlinJsr223JvmLocalScriptEngineFactory`
line should be added for Kotlin script support. See
https://github.com/sdeleuze/kotlin-script-templating[this example] for more details.
You need to have the script templating library. One way to do that for JavaScript is
through https://www.webjars.org/[WebJars].
[[mvc-view-script-integrate]]
== Script Templates
@ -49,7 +34,7 @@ through https://www.webjars.org/[WebJars].
@@ -49,7 +34,7 @@ through https://www.webjars.org/[WebJars].
You can declare a `ScriptTemplateConfigurer` bean to specify the script engine to use,
the script files to load, what function to call to render templates, and so on.
The following example uses Mustache templates and the Nashorn JavaScript engine:
The following example uses the Jython Python engine:
[tabs]
======
@ -58,7 +43,6 @@ Java::
@@ -58,7 +43,6 @@ Java::
[source,java,indent=0,subs="verbatim,quotes"]
----
@Configuration
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {
@Override
@ -69,9 +53,8 @@ Java::
@@ -69,9 +53,8 @@ Java::
@Bean
public ScriptTemplateConfigurer configurer() {
ScriptTemplateConfigurer configurer = new ScriptTemplateConfigurer();
fun configurer() = ScriptTemplateConfigurer().apply {
engineName = "nashorn"
setScripts("mustache.js")
renderObject = "Mustache"
engineName = "jython"
setScripts("render.py")
renderFunction = "render"
}
}
----
======
The following example shows the same arrangement in XML:
XML::
+
[source,xml,indent=0,subs="verbatim,quotes"]
----
<mvc:annotation-driven/>
@ -111,12 +91,22 @@ The following example shows the same arrangement in XML:
@@ -111,12 +91,22 @@ The following example shows the same arrangement in XML:
@ -143,7 +143,7 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
@@ -143,7 +143,7 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
@ -144,7 +144,7 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
@@ -144,7 +144,7 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {