Class ThymeleafModule
- java.lang.Object
-
- com.google.inject.AbstractModule
-
- ratpack.guice.ConfigurableModule<ThymeleafModule.Config>
-
- ratpack.thymeleaf.ThymeleafModule
-
- All Implemented Interfaces:
Module
@Deprecated public class ThymeleafModule extends ConfigurableModule<ThymeleafModule.Config>
Deprecated.since 1.7.0. Useratpack-thymeleaf3
instead.An extension module that provides support for Thymeleaf templating engine.To use it one has to register the module and then render
Template
instances. Instances ofTemplate
can be created using one of theTemplate.thymeleafTemplate(java.util.Map, String, String)
static methods.By default templates are looked up in the
thymeleaf
directory of the application root with a.html
suffix. SothymeleafTemplate("my/template/path")
maps tothymeleaf/my/template/path.html
in the application root directory. This can be configured usingsetTemplatesPrefix(String)
andsetTemplatesSuffix(String)
as well as configuration ofThymeleafModule.Config.templatesPrefix(String)
andThymeleafModule.Config.templateSuffix(String)
.Response content type can be manually specified, i.e.
thymeleafTemplate("template", model, "text/html")
if not specified will default totext/html
.import ratpack.guice.Guice; import ratpack.test.embed.EphemeralBaseDir; import ratpack.test.embed.EmbeddedApp; import java.nio.file.Path; import static org.junit.Assert.*; @SuppressWarnings("deprecation") public class Example { public static void main(String... args) throws Exception { EphemeralBaseDir.tmpDir().use(baseDir -> { baseDir.write("thymeleaf/myTemplate.html", "<span th:text=\"${key}\"/>"); EmbeddedApp.of(s -> s .serverConfig(c -> c.baseDir(baseDir.getRoot())) .registry(Guice.registry(b -> b.module(ratpack.thymeleaf.ThymeleafModule.class))) .handlers(chain -> chain .get(ctx -> ctx.render(ratpack.thymeleaf.Template.thymeleafTemplate("myTemplate", m -> m.put("key", "Hello Ratpack!")))) ) ).test(httpClient -> { assertEquals("<span>Hello Ratpack!</span>", httpClient.getText()); }); }); } }
To register dialects, use Guice Multibindings to bind an implementation of
IDialect
in a module.- See Also:
- Thymeleaf, Guice Multibindings
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ThymeleafModule.Config
Deprecated.The configuration object forThymeleafModule
.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_TEMPLATE_MODE
Deprecated.static java.lang.String
DEFAULT_TEMPLATE_PREFIX
Deprecated.static java.lang.String
DEFAULT_TEMPLATE_SUFFIX
Deprecated.
-
Constructor Summary
Constructors Constructor Description ThymeleafModule()
Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
configure()
Deprecated.java.lang.Integer
getTemplatesCacheSize()
Deprecated.java.lang.String
getTemplatesMode()
Deprecated.java.lang.String
getTemplatesPrefix()
Deprecated.java.lang.String
getTemplatesSuffix()
Deprecated.void
setTemplatesCacheSize(java.lang.Integer templatesCacheSize)
Deprecated.void
setTemplatesMode(java.lang.String templatesMode)
Deprecated.void
setTemplatesPrefix(java.lang.String templatesPrefix)
Deprecated.void
setTemplatesSuffix(java.lang.String templatesSuffix)
Deprecated.-
Methods inherited from class ratpack.guice.ConfigurableModule
configure, createConfig, defaultConfig, setConfig
-
Methods inherited from class com.google.inject.AbstractModule
addError, addError, addError, bind, bind, bind, bindConstant, binder, bindInterceptor, bindListener, bindListener, bindScope, configure, convertToTypes, currentStage, getMembersInjector, getMembersInjector, getProvider, getProvider, install, requestInjection, requestStaticInjection, requireBinding, requireBinding
-
-
-
-
Field Detail
-
DEFAULT_TEMPLATE_MODE
public static final java.lang.String DEFAULT_TEMPLATE_MODE
Deprecated.- See Also:
- Constant Field Values
-
DEFAULT_TEMPLATE_PREFIX
public static final java.lang.String DEFAULT_TEMPLATE_PREFIX
Deprecated.- See Also:
- Constant Field Values
-
DEFAULT_TEMPLATE_SUFFIX
public static final java.lang.String DEFAULT_TEMPLATE_SUFFIX
Deprecated.- See Also:
- Constant Field Values
-
-
Method Detail
-
getTemplatesMode
public java.lang.String getTemplatesMode()
Deprecated.
-
setTemplatesMode
public void setTemplatesMode(java.lang.String templatesMode)
Deprecated.
-
getTemplatesPrefix
public java.lang.String getTemplatesPrefix()
Deprecated.
-
setTemplatesPrefix
public void setTemplatesPrefix(java.lang.String templatesPrefix)
Deprecated.
-
getTemplatesSuffix
public java.lang.String getTemplatesSuffix()
Deprecated.
-
setTemplatesSuffix
public void setTemplatesSuffix(java.lang.String templatesSuffix)
Deprecated.
-
getTemplatesCacheSize
public java.lang.Integer getTemplatesCacheSize()
Deprecated.
-
setTemplatesCacheSize
public void setTemplatesCacheSize(java.lang.Integer templatesCacheSize)
Deprecated.
-
configure
protected void configure()
Deprecated.- Specified by:
configure
in classAbstractModule
-
-