Skip to content

Commit bfbb720

Browse files
author
Dave Syer
committed
Add docs for Groovy Templates
1 parent 2cadf41 commit bfbb720

File tree

3 files changed

+42
-13
lines changed

3 files changed

+42
-13
lines changed

spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,21 @@ content into your application; rather pick only the properties that you need.
9494
spring.freemarker.exposeSpringMacroHelpers=false
9595
spring.freemarker.prefix=
9696
spring.freemarker.requestContextAttribute=
97-
spring.freemarker.suffix=
97+
spring.freemarker.suffix=.ftl
9898
spring.freemarker.templateEncoding=UTF-8
9999
spring.freemarker.templateLoaderPath=classpath:/templates/
100-
spring.freemarker.viewNames=
100+
spring.freemarker.viewNames= # whitelist of view names that can be resolved
101+
102+
# GROOVY TEMPLATES ({sc-spring-boot-autoconfigure}}/groovy/template/GroovyTemplateAutoConfiguration.{sc-ext}[GroovyTemplateAutoConfiguration])
103+
spring.groovy.template.allowRequestOverride=false
104+
spring.groovy.template.allowSessionOverride=false
105+
spring.groovy.template.cache=true
106+
spring.groovy.template.contentType=text/html
107+
spring.groovy.template.prefix=classpath:/templates/
108+
spring.groovy.template.suffix=.tpl
109+
spring.groovy.template.templateEncoding=UTF-8
110+
spring.groovy.template.viewNames= # whitelist of view names that can be resolved
111+
spring.groovy.template.configuration.*= # See Groovy's TemplateConfiguration
101112
102113
# INTERNATIONALIZATION ({sc-spring-boot-autoconfigure}/MessageSourceAutoConfiguration.{sc-ext}[MessageSourceAutoConfiguration])
103114
spring.messages.basename=messages

spring-boot-docs/src/main/asciidoc/howto.adoc

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,8 +816,16 @@ added.
816816
and `spring.freemarker.suffix`, defaults ``'' and ``.ftl'' respectively). It can be overriden
817817
by providing a bean of the same name.
818818

819+
* If you use Groovy templates (actually if groovy-templates is on your classpath) you
820+
also have a `Groovy TemplateViewResolver` with id
821+
``groovyTemplateViewResolver''. It looks for resources in a loader path by
822+
surrounding the view name with a prefix and suffix (externalized to `spring.groovy.template.prefix`
823+
and `spring.groovy.template.suffix`, defaults ``classpath:/templates/'' and ``.tpl'' respectively). It can be overriden
824+
by providing a bean of the same name.
825+
819826
Check out {sc-spring-boot-autoconfigure}/web/WebMvcAutoConfiguration.{sc-ext}[`WebMvcAutoConfiguration`],
820-
{sc-spring-boot-autoconfigure}/thymeleaf/ThymeleafAutoConfiguration.{sc-ext}[`ThymeleafAutoConfiguration`], and
827+
{sc-spring-boot-autoconfigure}/thymeleaf/ThymeleafAutoConfiguration.{sc-ext}[`ThymeleafAutoConfiguration`],
828+
{sc-spring-boot-autoconfigure}/groovy/template/GroovyTemplateAutoConfiguration.{sc-ext}['GroovyTemplateAutoConfiguration'] and
821829
{sc-spring-boot-autoconfigure}/freemarker/FreeMarkerAutoConfiguration.{sc-ext}['FreeMarkerAutoConfiguration']
822830

823831

@@ -1381,14 +1389,19 @@ If you are using Thymeleaf, then set `spring.thymeleaf.cache` to `false`. See
13811389
for other Thymeleaf customization options.
13821390

13831391

1384-
13851392
[[howto-reload-freemarker-content]]
13861393
=== Reload FreeMarker templates without restarting the container
13871394
If you are using FreeMarker, then set `spring.freemarker.cache` to `false`. See
13881395
{sc-spring-boot-autoconfigure}/freemarker/FreeMarkerAutoConfiguration.{sc-ext}[`FreeMarkerAutoConfiguration`]
13891396
for other FreeMarker customization options.
13901397

13911398

1399+
[[howto-reload-groovy-template-content]]
1400+
=== Reload Groovy templates without restarting the container
1401+
If you are using Groovy templates, then set `spring.groovy.template.cache` to `false`. See
1402+
{sc-spring-boot-autoconfigure}/groovy/template/GroovyTemplateAutoConfiguration.{sc-ext}[`GroovyTemplateAutoConfiguration`]
1403+
for other Groovy customization options.
1404+
13921405

13931406
[[howto-reload-java-classes-without-restarting]]
13941407
=== Reload Java classes without restarting the container

spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -905,15 +905,20 @@ and it will be silently ignored by most build tools if you generate a jar.
905905

906906
[[boot-features-spring-mvc-template-engines]]
907907
==== Template engines
908-
As well as REST web services, you can also use Spring MVC to serve dynamic HTML content.
909-
Spring MVC supports a variety of templating technologies including: Velocity, FreeMarker,
910-
and JSPs. Many other templating engines also ship their own Spring MVC integrations.
911-
912-
Spring Boot includes auto-configuration support for the Thymeleaf and FreeMarker
913-
templating engines. Thymeleaf is an XML/XHTML/HTML5 template engine that can work both in
914-
web and non-web environments. If allows you to create natural templates that can be
915-
correctly displayed by browsers and therefore work also as static prototypes. Both
916-
FreeMarker and Thymeleaf templates will be picked up automatically from
908+
909+
As well as REST web services, you can also use Spring MVC to serve
910+
dynamic HTML content. Spring MVC supports a variety of templating
911+
technologies including: Velocity, FreeMarker and JSPs. Many
912+
other templating engines also ship their own Spring MVC integrations.
913+
914+
Spring Boot includes auto-configuration support for the Thymeleaf,
915+
[FreeMarker](http://freemarker.org/docs/) and
916+
[Groovy](http://beta.groovy-lang.org/docs/groovy-2.3.0/html/documentation/markup-template-engine.html)
917+
templating engines. Thymeleaf is an XML/XHTML/HTML5 template engine
918+
that can work both in web and non-web environments. If allows you to
919+
create natural templates that can be correctly displayed by browsers
920+
and therefore work also as static prototypes. Your FreeMarker, Groovy
921+
and Thymeleaf templates will be picked up automatically from
917922
`src/main/resources/templates`.
918923

919924

0 commit comments

Comments
 (0)