allegro/handlebars-spring-boot-starter

Name: handlebars-spring-boot-starter

Owner: Allegro Tech

Description: Spring Boot auto-configuration for Handlebars

Created: 2015-04-01 10:49:00.0

Updated: 2018-05-24 06:12:32.0

Pushed: 2018-03-10 16:03:53.0

Homepage:

Size: 198

Language: Groovy

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

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:

sitories {
mavenCentral()


ndencies {
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.

ndencies {
compile 'com.github.jknack:handlebars-helpers:4.0.6',
        'com.github.jknack:handlebars-jackson2:4.0.6',
        'com.github.jknack:handlebars-humanize:4.0.6',
        'com.github.jknack:handlebars-markdown:4.0.6'

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
dlebarsHelper
ic 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:

lebars.enabled: true
lebars.prefix: classpath:templates/
lebars.suffix: .hbs
lebars.cache: true
lebars.registerMessageHelper: true
lebars.failOnMissingFile: false
lebars.bindI18nToMessageSource: false
lebars.prettyPrint: false
lebars.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:

lebars.resolver.javaBean: true
lebars.resolver.map: true
lebars.resolver.method: false
lebars.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.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.