Spring Boot Starter Handlebars

Spring Boot auto-configuration for Handlebars template engine

License

License

Categories

Categories

Spring Boot Container Microservices
GroupId

GroupId

pl.allegro.tech.boot
ArtifactId

ArtifactId

spring-boot-starter-handlebars
Last Version

Last Version

0.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

Spring Boot Starter Handlebars
Spring Boot auto-configuration for Handlebars template engine
Project URL

Project URL

https://github.com/allegro/spring-boot-starter-handlebars
Source Code Management

Source Code Management

https://github.com/allegro/spring-boot-starter-handlebars

Download spring-boot-starter-handlebars

How to add to project

<!-- https://jarcasting.com/artifacts/pl.allegro.tech.boot/spring-boot-starter-handlebars/ -->
<dependency>
    <groupId>pl.allegro.tech.boot</groupId>
    <artifactId>spring-boot-starter-handlebars</artifactId>
    <version>0.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/pl.allegro.tech.boot/spring-boot-starter-handlebars/
implementation 'pl.allegro.tech.boot:spring-boot-starter-handlebars:0.1.1'
// https://jarcasting.com/artifacts/pl.allegro.tech.boot/spring-boot-starter-handlebars/
implementation ("pl.allegro.tech.boot:spring-boot-starter-handlebars:0.1.1")
'pl.allegro.tech.boot:spring-boot-starter-handlebars:jar:0.1.1'
<dependency org="pl.allegro.tech.boot" name="spring-boot-starter-handlebars" rev="0.1.1">
  <artifact name="spring-boot-starter-handlebars" type="jar" />
</dependency>
@Grapes(
@Grab(group='pl.allegro.tech.boot', module='spring-boot-starter-handlebars', version='0.1.1')
)
libraryDependencies += "pl.allegro.tech.boot" % "spring-boot-starter-handlebars" % "0.1.1"
[pl.allegro.tech.boot/spring-boot-starter-handlebars "0.1.1"]

Dependencies

compile (8)

Group / Artifact Type Version
com.github.jknack : handlebars-springmvc jar 2.0.0
com.github.jknack : handlebars-jackson2 Optional jar 2.0.0
org.springframework.boot : spring-boot-starter-web jar 1.2.3.RELEASE
com.github.jknack : handlebars-humanize Optional jar 2.0.0
com.github.jknack : handlebars-guava-cache jar 2.0.0
com.github.jknack : handlebars-markdown Optional jar 2.0.0
joda-time : joda-time Optional jar 2.7
com.github.jknack : handlebars-helpers Optional jar 2.0.0

test (2)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-test jar 1.2.3.RELEASE
org.spockframework : spock-core jar 1.0-groovy-2.4

Project Modules

There are no modules declared in this project.

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.2'
}

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.2.0',
            'com.github.jknack:handlebars-jackson2:4.2.0',
            'com.github.jknack:handlebars-humanize:4.2.0',
            'com.github.jknack:handlebars-markdown:4.2.0'
}

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.

pl.allegro.tech.boot

Allegro Tech

Allegro Tech Open Source Projects

Versions

Version
0.1.1
0.1.0