Spring Boot auto-configuration for Handlebars
Latest commit d37a9c7 Aug 28, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config Initial commit Apr 1, 2015
gradle/wrapper support spring boot 2 (#27) Mar 8, 2018
src support spring boot 2 (#27) Mar 8, 2018
test-dependencies support spring boot 2 (#27) Mar 8, 2018
.gitignore rename Apr 11, 2015
.travis.yml support spring boot 2 (#27) Mar 8, 2018
LICENSE Initial commit Apr 1, 2015
README.md Revert README.md minor versions 0.3.1 to 0.3.0 Aug 28, 2018
build.gradle Update build.gradle Aug 26, 2018
gradlew Initial commit Apr 1, 2015
gradlew.bat Initial commit Apr 1, 2015
settings.gradle rename Apr 11, 2015

README.md

Spring Boot Starter Handlebars

Build Status Coverage Status Maven Central

Spring Boot Starter support for Handlebars.java (logic-less templates).

Usage

Add handlebars-spring-boot-starter as dependency:

repositories {
    mavenCentral()
}

dependencies {
    compile 'pl.allegro.tech.boot:handlebars-spring-boot-starter:0.3.0'
}

Requirements

Since version 0.3.0 handlebars-spring-boot-starter requires Spring Boot 2.0, Spring Framework 5 and Java 8.

Helpers

Spring Boot Starter Handlebars will automatically register handlebars helpers based on project dependencies. Add any handlebars helper to dependencies and you can start using it.

dependencies {
    compile 'com.github.jknack:handlebars-helpers:4.0.7',
            'com.github.jknack:handlebars-jackson2:4.0.7',
            'com.github.jknack:handlebars-humanize:4.0.7',
            'com.github.jknack:handlebars-markdown:4.0.7'
}

NOTE: Jackson2Helper and MarkdownHelper will register with name json and md respectively. Every other helper will register with its default name.

More information about available helpers can be found on Handlebars.java.

Custom helpers

To register a custom helper use @HandlebarsHelper annotation.

Example

@HandlebarsHelper
public class CustomHelper {
    CharSequence foo() {
        return 'bar'
    }
}

More information about how to create custom helpers can be found on Using a HelperSource

Configuration

Properties space is: handlebars. All basic properties of AbstractTemplateViewResolverProperties.java are available.

Default configuration:

handlebars.enabled: true
handlebars.prefix: classpath:templates/
handlebars.suffix: .hbs
handlebars.cache: true
handlebars.registerMessageHelper: true
handlebars.failOnMissingFile: false
handlebars.bindI18nToMessageSource: false
handlebars.prettyPrint: false
handlebars.infiniteLoops: false

NOTE: handlebars-guava-cache is used as template cache implementation.

resolver configuration allows on/off available handlebars value resolvers. Here goes default configuration:

handlebars.resolver.javaBean: true
handlebars.resolver.map: true
handlebars.resolver.method: false
handlebars.resolver.field: false

More information about value resolvers can be found on Using the ValueResolver.

Custom cache template

Set handlebars template cache by @Bean of type TemplateCache.

Custom template loader

Set handlebars template loader by @Bean of type TemplateLoader.

License

handlebars-spring-boot-starter is published under Apache License 2.0.