Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/allegro/handlebars-spring-boot-starter
Spring Boot auto-configuration for Handlebars
https://github.com/allegro/handlebars-spring-boot-starter
hacktoberfest handlers spring-boot spring-boot-starter
Last synced: 3 days ago
JSON representation
Spring Boot auto-configuration for Handlebars
- Host: GitHub
- URL: https://github.com/allegro/handlebars-spring-boot-starter
- Owner: allegro
- License: apache-2.0
- Created: 2015-04-01T10:49:00.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-12-11T07:04:56.000Z (12 days ago)
- Last Synced: 2024-12-13T21:08:27.080Z (10 days ago)
- Topics: hacktoberfest, handlers, spring-boot, spring-boot-starter
- Language: Groovy
- Homepage:
- Size: 394 KB
- Stars: 109
- Watchers: 14
- Forks: 27
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Spring Boot Starter Handlebars
====[![Build Status](https://img.shields.io/github/actions/workflow/status/allegro/handlebars-spring-boot-starter/gradle.yml)](https://github.com/allegro/handlebars-spring-boot-starter/actions/workflows/gradle.yml)
[![Coverage Status](https://coveralls.io/repos/allegro/handlebars-spring-boot-starter/badge.svg)](https://coveralls.io/r/allegro/handlebars-spring-boot-starter)
![Maven Central](https://img.shields.io/maven-central/v/pl.allegro.tech.boot/handlebars-spring-boot-starter.svg)Spring Boot Starter support for
[Handlebars.java](https://github.com/jknack/handlebars.java)
(logic-less templates).## Usage
Add `handlebars-spring-boot-starter` as dependency:
```gradle
repositories {
mavenCentral()
}dependencies {
compile 'pl.allegro.tech.boot:handlebars-spring-boot-starter:$version'
}
```## Requirements
Since version 0.5.0 handlebars-spring-boot-starter requires Spring Boot 3, Spring Framework 6 and Java 17.
## 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.
```gradle
dependencies {
compile 'com.github.jknack:handlebars-helpers:4.4.0',
'com.github.jknack:handlebars-jackson:4.4.0'
}
```
NOTE: JacksonHelper will register with name `json`.
Every other helper will register with its default name.More information about available helpers can be found on
[Handlebars.java](https://github.com/jknack/handlebars.java#helpers).### Custom helpers
To register a custom helper use [@HandlebarsHelper](src/main/java/pl/allegro/tech/boot/autoconfigure/handlebars/HandlebarsHelper.java) annotation.
#### Example
```java
@HandlebarsHelper
public class CustomHelper {
CharSequence foo() {
return 'bar'
}
}
```
More information about how to create custom helpers can be found on [Using a HelperSource](https://github.com/jknack/handlebars.java#using-a-helpersource)## Configuration
Properties space is: `handlebars`. All basic properties of
[AbstractTemplateViewResolverProperties.java](http://docs.spring.io/autorepo/docs/spring-boot/current/api/org/springframework/boot/autoconfigure/template/AbstractTemplateViewResolverProperties.html)
are available.Default configuration:
```yaml
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:
```yaml
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](https://github.com/jknack/handlebars.java#using-the-valueresolver).### Custom cache template
Set handlebars template cache by `@Bean` of type [TemplateCache](https://github.com/jknack/handlebars.java/blob/master/handlebars/src/main/java/com/github/jknack/handlebars/cache/TemplateCache.java).
### Custom template loader
Set handlebars template loader by `@Bean` of type [TemplateLoader](https://github.com/jknack/handlebars.java/blob/master/handlebars/src/main/java/com/github/jknack/handlebars/io/TemplateLoader.java).
## License
**handlebars-spring-boot-starter** is published under [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0).