jtwig-hot-reloading-extension

Jtwig jtwig-hot-reloading-extension

License

License

GroupId

GroupId

org.jtwig
ArtifactId

ArtifactId

jtwig-hot-reloading-extension
Last Version

Last Version

5.86.1.RELEASE
Release Date

Release Date

Type

Type

jar
Description

Description

jtwig-hot-reloading-extension
Jtwig jtwig-hot-reloading-extension
Project URL

Project URL

http://jtwig.org
Source Code Management

Source Code Management

https://github.com/jtwig/jtwig-hot-reloading-extension

Download jtwig-hot-reloading-extension

How to add to project

<!-- https://jarcasting.com/artifacts/org.jtwig/jtwig-hot-reloading-extension/ -->
<dependency>
    <groupId>org.jtwig</groupId>
    <artifactId>jtwig-hot-reloading-extension</artifactId>
    <version>5.86.1.RELEASE</version>
</dependency>
// https://jarcasting.com/artifacts/org.jtwig/jtwig-hot-reloading-extension/
implementation 'org.jtwig:jtwig-hot-reloading-extension:5.86.1.RELEASE'
// https://jarcasting.com/artifacts/org.jtwig/jtwig-hot-reloading-extension/
implementation ("org.jtwig:jtwig-hot-reloading-extension:5.86.1.RELEASE")
'org.jtwig:jtwig-hot-reloading-extension:jar:5.86.1.RELEASE'
<dependency org="org.jtwig" name="jtwig-hot-reloading-extension" rev="5.86.1.RELEASE">
  <artifact name="jtwig-hot-reloading-extension" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.jtwig', module='jtwig-hot-reloading-extension', version='5.86.1.RELEASE')
)
libraryDependencies += "org.jtwig" % "jtwig-hot-reloading-extension" % "5.86.1.RELEASE"
[org.jtwig/jtwig-hot-reloading-extension "5.86.1.RELEASE"]

Dependencies

compile (3)

Group / Artifact Type Version
org.jtwig : jtwig-core jar 5.86.1.RELEASE
com.google.guava : guava jar 18.0
org.apache.commons : commons-lang3 jar 3.1

Project Modules

There are no modules declared in this project.

Jtwig Hot Reloading Extension

How to use?

  • Include the dependency in your project (check bintray).
  • Add to your custom Jtwig configuration
EnvironmentConfiguration configuration = EnvironmentConfigurationBuilder
    .configuration()
        .extensions()
            .add(new HotReloadingExtension(TimeUnit.SECONDS, 1))
        .and()
    .build();

How it works?

  • If the referenced resource is a file, it then checks for the last modified date and depending on such date, this may evict the cached template.

Integration with Spring Boot

Note that, jtwig-spring-boot-started module, by default, sets the template source as the classpath, bundling such application inside a standalone jar makes it impossible to edit such template files. For this to work, an easy solution can be to use templates stored in a specific directory, as shown in the example below:

@Configuration
public class JtwigConfig implements JtwigViewResolverConfigurer {
    @Override
    public void configure(JtwigViewResolver viewResolver) {
        viewResolver.setPrefix("file:/path/to/base/directory");
        viewResolver.setRenderer(new JtwigRenderer(EnvironmentConfigurationBuilder
                .configuration()
                .extensions().add(new HotReloadingExtension(TimeUnit.SECONDS, 1)).and()
                .build()));
    }
}

Build Stats

Build Status codecov Download

Licensing

Apache License

Requirements

  • Java 7
org.jtwig

Jtwig

Modern Java Template Engine

Versions

Version
5.86.1.RELEASE