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-thymeleaf3instead.An extension module that provides support for Thymeleaf templating engine.To use it one has to register the module and then render
Templateinstances. Instances ofTemplatecan be created using one of theTemplate.thymeleafTemplate(java.util.Map, String, String)static methods.By default templates are looked up in the
thymeleafdirectory of the application root with a.htmlsuffix. SothymeleafTemplate("my/template/path")maps tothymeleaf/my/template/path.htmlin 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
IDialectin a module.- See Also:
- Thymeleaf, Guice Multibindings
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classThymeleafModule.ConfigDeprecated.The configuration object forThymeleafModule.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_TEMPLATE_MODEDeprecated.static java.lang.StringDEFAULT_TEMPLATE_PREFIXDeprecated.static java.lang.StringDEFAULT_TEMPLATE_SUFFIXDeprecated.
-
Constructor Summary
Constructors Constructor Description ThymeleafModule()Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidconfigure()Deprecated.java.lang.IntegergetTemplatesCacheSize()Deprecated.java.lang.StringgetTemplatesMode()Deprecated.java.lang.StringgetTemplatesPrefix()Deprecated.java.lang.StringgetTemplatesSuffix()Deprecated.voidsetTemplatesCacheSize(java.lang.Integer templatesCacheSize)Deprecated.voidsetTemplatesMode(java.lang.String templatesMode)Deprecated.voidsetTemplatesPrefix(java.lang.String templatesPrefix)Deprecated.voidsetTemplatesSuffix(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.- Overrides:
configurein classAbstractModule
-
-