For the latest stable version, please use gotmpl4j Spring Boot 4.1.1.1!

Configuration

The Spring Boot starter is configured under the gotmpl4j prefix (Gotmpl4jProperties).

1. Core properties

Property Default Description

gotmpl4j.enabled

true

Enables the auto-configuration.

gotmpl4j.prefix

classpath:/templates/

Location templates are resolved from.

gotmpl4j.suffix

.gotmpl

File-name suffix appended to a view/template name.

gotmpl4j.mode

text

Rendering mode. text is Go text/template with no escaping (Helm-compatible). html enables Go html/template-style contextual auto-escaping (HTML/attribute/URL/JS/CSS aware).

gotmpl4j.order

LOWEST_PRECEDENCE - 10

Order of the view resolver, relative to other resolvers. Lower it when mixing template engines so gotmpl4j is consulted before a more greedy resolver.

gotmpl4j.charset

UTF-8

Charset used when reading templates and writing output.

gotmpl4j.cache

true

Caches compiled template ASTs. Disable during development for live reload.

gotmpl4j.view-names

(none)

If set, only these view names are resolved by the view resolver. Set this when mixing template engines so gotmpl4j does not greedily claim every view.

gotmpl4j.request-context-attribute

(none)

Name of the RequestContext exposed to the view, if any.

2. Servlet view properties

Under gotmpl4j.servlet:

Property Default Description

content-type

text/html

Response content type.

expose-request-attributes

false

Expose request attributes to the model.

expose-session-attributes

false

Expose session attributes to the model.

allow-request-override

false

Allow request attributes to override model attributes.

allow-session-override

false

Allow session attributes to override model attributes.

3. Reactive view properties

Under gotmpl4j.reactive:

Property Default Description

media-types

text/html

Supported media types for content negotiation.

4. Example

gotmpl4j:
  prefix: classpath:/views/
  suffix: .html
  cache: false            # live reload during development
  view-names:
    - "mail/*"