Skip to content

jtwig/jtwig-hot-reloading-extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages