Jtwig Spring

Project jtwig-spring

The jtwig-spring project includes implementations of Spring View and ViewResolver, allowing one to integrate Jtwig with Spring MVC.

@Configuration
@EnableWebMvc
public class WebConfig {
    @Bean
    public ViewResolver viewResolver () {
        JtwigViewResolver viewResolver = new JtwigViewResolver();
        viewResolver.setPrefix("web:/WEB-INF/templates/");
        viewResolver.setSuffix(".twig.html");
        return viewResolver;
    }
}

The example above defines the ViewResolver bean used by Spring MVC to render a given view. The example shown here can be found in jtwig-examples.

Integrating

Integrating Jtwig Spring on your project is quite simple with the help of dependency managers. To check the most recent version, go to bintray.

Gradle

repositories {
    jcenter()
}
dependencies {
    compile 'org.jtwig:jtwig-spring:5.X'
}

Maven

<repositories>
    <repository>
        <id>bintray</id>
        <url>https://jcenter.bintray.com/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>org.jtwig</groupId>
        <artifactId>jtwig-spring</artifactId>
        <version>5.X</version>
    </dependency>
</dependencies>