Spring Boot Starter Handlebars
Nowadays, Spring Boot gets more and more popular as it simplifies creating standalone, production-grade Spring based applications. It offers e.g. auto-configuration support for most of the available Java-based template engines such as Velocity, Thymeleaf, etc. Today, we would like to publish the new Spring Boot starter that supports auto-configuration of other popular template engine we have recently got used to — Handlebars. Hopefully you might find this little piece of code useful.
Follow Spring Boot for further information about its auto-configuration and other helpful features.
Usage #
As you can expect for any Spring Boot starter its use is pretty straightforward. Just add
handlebars-spring-boot-starter to dependencies of your Spring Boot application and your Handlebars templates will be
picked up automatically from src/main/resources/templates
.
repositories {
mavenCentral()
}
dependencies {
compile 'pl.allegro.tech.boot:handlebars-spring-boot-starter:0.2.0'
}
Naturally, you can customize configuration settings. Check README.md to find custom configuration examples.
Example Spring Boot application #
src/main/resources/templates/index.hbs
src/main/java/Application.java
@Controller
@SpringBootApplication
public static class Application {
@RequestMapping("/")
public String index(Model model) {
model.addAttribute("foo", "Hello Handlebars!");
return "index";
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Now start the application and go to http://localhost:8080.
Where can I find it? #
handlebars-spring-boot-starter is published under Apache License 2.0 at Allegro Github account along with the other Allegro OpenSource projects and released to Maven Central. To find out more about it, check README.md located in handlebars-spring-boot-starter repository.