Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
5b9d255
helper: remove humanize helpers fix #912
edgar-espina-wpp Mar 2, 2024
70d9261
java 17: build upgrade
edgar-espina-wpp Mar 2, 2024
2bb3465
build: remove checkstyle
edgar-espina-wpp Mar 3, 2024
94d5e8b
build: add spotless
edgar-espina-wpp Mar 3, 2024
2f65787
build: apply spotless
edgar-espina-wpp Mar 3, 2024
5ba0ea0
build: init mustache specs as part of normal build
edgar-espina-wpp Mar 3, 2024
b7b999a
build: junit 5
edgar-espina-wpp Mar 3, 2024
4931bc5
build: remove pegdown dependency
edgar-espina-wpp Mar 3, 2024
f991892
build: upgrade spring version to 6.x
edgar-espina-wpp Mar 3, 2024
e7a1093
build: upgrade slf4j to 2.x
edgar-espina-wpp Mar 3, 2024
a355f43
build: version bump
edgar-espina-wpp Mar 4, 2024
726db2e
build: update maven plugin dependencies
edgar-espina-wpp Mar 4, 2024
5df47e3
build: spring remove vulnerability
edgar-espina-wpp Mar 4, 2024
cd2d035
build: update maven plugin dependencies
edgar-espina-wpp Mar 4, 2024
d09b3c8
java modules: modularize handlebars modules
edgar-espina-wpp Mar 4, 2024
0864c16
docs: update doc to reflect Java 17 support
edgar-espina-wpp Mar 4, 2024
d8ff863
java modules: convert missing jackson module
edgar-espina-wpp Mar 4, 2024
7914400
build: rename tests module
edgar-espina-wpp Mar 7, 2024
878e965
build: rename sonatype profile to central
edgar-espina-wpp Mar 7, 2024
d840749
build: release to central action
edgar-espina-wpp Mar 7, 2024
dda4d71
v4.4.0
edgar-espina-wpp Mar 7, 2024
dc2cebf
build(deps): bump com.google.javascript:closure-compiler
dependabot[bot] Mar 8, 2024
377b229
build(deps-dev): bump org.junit.platform:junit-platform-suite
dependabot[bot] Mar 8, 2024
4fc3e37
build(deps-dev): bump commons-io:commons-io from 2.11.0 to 2.15.1
dependabot[bot] Mar 8, 2024
3c48c1e
build(deps): bump ch.qos.logback:logback-classic from 1.5.2 to 1.5.3
dependabot[bot] Mar 8, 2024
e8a9f24
build(deps): bump spring.version from 6.0.14 to 6.1.4
dependabot[bot] Mar 8, 2024
1a6937c
build(deps): bump org.codehaus.mojo:build-helper-maven-plugin
dependabot[bot] Mar 8, 2024
3f71f2b
build(deps): bump org.apache.felix:maven-bundle-plugin
dependabot[bot] Mar 8, 2024
c8fd5cc
build(deps): bump org.apache.maven.plugins:maven-jar-plugin
dependabot[bot] Mar 8, 2024
e462ef6
build: upgrade plexus-utils
jknack Mar 10, 2024
c8b69f6
build(deps): bump jakarta.servlet:jakarta.servlet-api
dependabot[bot] Mar 8, 2024
9c8efc2
build: fix javadoc
jknack Mar 10, 2024
5e755f3
prepare for next development cycle
jknack Mar 10, 2024
3b1f0d6
build(deps): bump org.codehaus.plexus:plexus-xml from 4.0.0 to 4.0.3
dependabot[bot] Mar 11, 2024
5f6a411
build(deps): bump com.fasterxml.jackson.core:jackson-databind
dependabot[bot] Mar 11, 2024
84ade35
build(deps): bump org.apache.maven.plugins:maven-gpg-plugin
dependabot[bot] Mar 11, 2024
0e1ec8b
build: group dependabot dependencies
jknack Mar 18, 2024
3bb0839
build(deps): bump com.fasterxml.jackson.core:jackson-databind
dependabot[bot] Mar 13, 2024
41c0b01
build(deps): bump the dependencies group with 5 updates
dependabot[bot] Mar 18, 2024
e96b991
build(deps): bump the dependencies group with 2 updates
dependabot[bot] Mar 25, 2024
5d74c97
build(deps): bump the dependencies group with 15 updates
dependabot[bot] Apr 22, 2024
1f201dd
build(deps): bump the dependencies group across 1 directory with 11 u…
dependabot[bot] May 20, 2024
42c1912
build(deps): bump the dependencies group across 1 directory with 20 u…
dependabot[bot] Jul 1, 2024
73cb79d
Fix #1162 - Bump commons-lang3 to fix CVE-2025-48924
tingley Jul 18, 2025
7d49fbb
Fix typo
fatalistt Apr 12, 2025
978ec5e
Rework append for better memory efficiency
MiguelAMarcelino Jan 27, 2025
922e24a
java: remove multiple checks for JVM version
jknack Aug 7, 2025
7c2dce9
[ISSUE-996] Support includeZero option in IF Helper
clementgbcn Oct 25, 2024
65f8980
Fix invalid Java token error
chrisrueger Dec 4, 2021
275b5ec
fix(issue-1160): support named 'locale' and 'format' parameters
LeoFuso Jun 9, 2025
a5ccf61
change parsing rule to disallow multiple else statements
Dec 8, 2024
bb6beae
build: dependency upgrades
jknack Aug 7, 2025
5f3eeff
build: dependency upgrades
jknack Aug 7, 2025
63a20c4
prepare for maven release
jknack Aug 7, 2025
8bbe995
prepare for maven release
jknack Aug 7, 2025
7bebbef
prepare for maven release
jknack Aug 7, 2025
827e6bc
Java 21 ArrayList getLast is resolved by JavaBeanValueResolver
jknack Aug 7, 2025
83bd602
Add Java 21 to CI
dsvensson Jul 8, 2024
ef789e6
v4.5.0
jknack Aug 7, 2025
0108802
prepare for next development cycle
jknack Aug 7, 2025
131c734
joda: remove stupid test with special whitespace
jknack Aug 7, 2025
b8a94d3
build: update GH actions
jknack Aug 7, 2025
31bd065
Upgrade to latest handlebars.js (4.7.9) as 4.7.7 has security issues.
campeis Apr 11, 2026
2c2899b
v4.5.1
jknack May 5, 2026
ddd22a9
build: version bump
jknack May 5, 2026
620ef84
build: revert closure-compiler, latest version are Java 21 only
jknack May 5, 2026
09779a9
build: upgrade antlr to latest
jknack May 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
39 changes: 6 additions & 33 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,9 @@ updates:
- package-ecosystem: maven
directory: "/"
schedule:
interval: daily
time: "09:00"
open-pull-requests-limit: 10
ignore:
- dependency-name: org.springframework:spring-test
versions:
- ">= 5.a, < 6"
- dependency-name: com.google.javascript:closure-compiler
versions:
- v20210106
- v20210202
- v20210302
- dependency-name: org.eclipse.jetty:jetty-servlet
versions:
- 11.0.0
- 11.0.1
- dependency-name: org.eclipse.jetty:jetty-webapp
versions:
- 11.0.0
- 11.0.1
- dependency-name: org.eclipse.jetty:jetty-server
versions:
- 11.0.0
- 11.0.1
- dependency-name: org.yaml:snakeyaml
versions:
- "1.27"
- dependency-name: org.apache.commons:commons-lang3
versions:
- "3.11"
- dependency-name: org.apache.felix:maven-bundle-plugin
versions:
- 5.1.1
interval: weekly
open-pull-requests-limit: 1
groups:
dependencies:
patterns:
- "*"
20 changes: 9 additions & 11 deletions .github/workflows/build-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,24 @@ jobs:
strategy:
fail-fast: false
matrix:
java_version: [1.8, 11, 15, 17]
os: [ubuntu-latest, windows-latest, macOS-latest]
jre: [17]
os: [ ubuntu-latest, windows-latest, macOS-latest ]
include:
- jre: 21
os: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v4
- name: Mustache Specs
run: |
git submodule update --init --recursive
- name: Set up JDK ${{ matrix.java_version }}
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java_version }}
java-version: ${{ matrix.jre }}
distribution: 'temurin'
- name: Install
run: mvn clean install -DskipTests --batch-mode --no-transfer-progress
env:
BUILD_PORT: 0
BUILD_SECURE_PORT: 0
- name: Build
run: mvn clean package --batch-mode --no-transfer-progress
env:
BUILD_PORT: 0
BUILD_SECURE_PORT: 0
38 changes: 38 additions & 0 deletions .github/workflows/maven-central.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Maven Central

on:
release:
types: [created]

jobs:
release:
name: Maven Central
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
cache: maven
- name: Build
run: mvn clean install -DskipTests -q
- name: Set up Maven Central
uses: actions/setup-java@v3
with: # running setup-java again overwrites the settings.xml
java-version: 17
distribution: 'temurin'
server-id: central
server-username: CENTRAL_USERNAME
server-password: CENTRAL_TOKEN
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Publish to Maven Central
run: mvn -pl '!tests' clean deploy -P central
env:
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
CENTRAL_TOKEN: ${{ secrets.CENTRAL_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ pom.xml.versionsBackup
jacoco.exec

out
tmp
tmp/spotless
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

57 changes: 8 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Handlebars provides the power necessary to let you build semantic templates effe

# Requirements

- Handlebars 4.3+ requires Java 8 or higher.
- Handlebars 4.4+ requires Java 17 or higher.
- Handlebars 4.3+ requires Java 8 or higher (NOT MAINTAINED).


# Getting Started
Expand Down Expand Up @@ -61,9 +62,9 @@ Hello {{this}}!
```

```java
Handlebars handlebars = new Handlebars();
var handlebars = new Handlebars();

Template template = handlebars.compile("mytemplate");
var template = handlebars.compile("mytemplate");

System.out.println(template.apply("Handlebars.java"));
```
Expand Down Expand Up @@ -544,8 +545,8 @@ Template template = handlebars.compileInline("{{#blog-list blogs}}{{/blog-list}}
```java
handlebars.registerHelper("blog-list", new Helper<Blog>() {
public CharSequence apply(List<Blog> list, Options options) {
String class = options.hash("class");
assertEquals("blog-css", class);
String classParam = options.hash("class");
assertEquals("blog-css", classParam);
...
}
});
Expand Down Expand Up @@ -885,58 +886,17 @@ escapeHTML: True, if the JSON content contains HTML chars and you need to escape

pretty: True, if the JSON content must be formatted. Default is: false.

## Jackson 2.x
## Jackson

Maven:
```xml
<dependency>
<groupId>com.github.jknack</groupId>
<artifactId>handlebars-jackson2</artifactId>
<artifactId>handlebars-jackson</artifactId>
<version>${handlebars-version}</version>
</dependency>
```

Same as Jackson1.x, except for the name of the helper: ```Jackson2Helper```

## Markdown

Maven:
```xml
<dependency>
<groupId>com.github.jknack</groupId>
<artifactId>handlebars-markdown</artifactId>
<version>${handlebars-version}</version>
</dependency>
```
Usage:

```java
handlebars.registerHelper("md", new MarkdownHelper());
```
```
{{md context}}
```
context: An object or null. Required.

## Humanize

Maven:
```xml
<dependency>
<groupId>com.github.jknack</groupId>
<artifactId>handlebars-humanize</artifactId>
<version>${handlebars-version}</version>
</dependency>
```
Usage:

```java
// Register all the humanize helpers.
HumanizeHelper.register(handlebars);
```

See the JavaDoc of the [HumanizeHelper] (https://github.com/jknack/handlebars.java/blob/master/handlebars-humanize/src/main/java/com/github/jknack/handlebars/HumanizeHelper.java) for more information.

## SpringMVC

Maven:
Expand Down Expand Up @@ -1063,7 +1023,6 @@ Hello {{#child}}{{this.value}}{{/child}}
* [Handlebars.js](http://handlebarsjs.com/)
* [Try Handlebars.js](http://tryhandlebarsjs.com/)
* [Mustache](http://mustache.github.io/)
* [Humanize](https://github.com/mfornos/humanize)
* [ANTLRv4](http://www.antlr.org/)

## Author
Expand Down
1 change: 0 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Java 15/17 Migration

- Replace pegdown with something else
- Upgrade spring
30 changes: 11 additions & 19 deletions handlebars-caffeine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
<parent>
<groupId>com.github.jknack</groupId>
<artifactId>handlebars.java</artifactId>
<version>5.0.0-SNAPSHOT</version>
<version>4.5.1</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<groupId>com.github.jknack</groupId>
<artifactId>handlebars-caffeine</artifactId>

<name>Handlebars Caffeine Cache</name>
Expand All @@ -24,14 +23,7 @@
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>2.9.2</version>
</dependency>

<!-- Servlet API -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope>
<version>3.1.8</version>
</dependency>

<!-- Test dependencies -->
Expand All @@ -50,14 +42,8 @@
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>

Expand All @@ -70,7 +56,7 @@
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>4.9.3</version>
<version>${antlr-version}</version>
<exclusions>
<exclusion>
<groupId>org.abego.treelayout</groupId>
Expand All @@ -85,6 +71,12 @@
<artifactId>commons-text</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
/**
* Copyright (c) 2012-2015 Edgar Espina
*
* This file is part of Handlebars.java.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
/*
* Handlebars.java: https://github.com/jknack/handlebars.java
* Apache License Version 2.0 http://www.apache.org/licenses/LICENSE-2.0
* Copyright (c) 2012 Edgar Espina
*/
package com.github.jknack.handlebars.cache;
package com.github.jknack.handlebars.caffeine;

import static java.util.Objects.requireNonNull;

Expand All @@ -26,6 +14,7 @@
import com.github.jknack.handlebars.Handlebars;
import com.github.jknack.handlebars.Parser;
import com.github.jknack.handlebars.Template;
import com.github.jknack.handlebars.cache.TemplateCache;
import com.github.jknack.handlebars.io.TemplateSource;

/**
Expand All @@ -36,9 +25,7 @@
*/
public class CaffeineTemplateCache implements TemplateCache {

/**
* Internal cache.
*/
/** Internal cache. */
private final Cache<TemplateSource, Template> cache;

/**
Expand All @@ -50,28 +37,32 @@ public CaffeineTemplateCache(final Cache<TemplateSource, Template> cache) {
this.cache = requireNonNull(cache, "The cache is required.");
}

@Override public void clear() {
@Override
public void clear() {
cache.invalidateAll();
}

@Override public void evict(final TemplateSource source) {
@Override
public void evict(final TemplateSource source) {
cache.invalidate(source);
}

@Override public Template get(final TemplateSource source, final Parser parser) {
@Override
public Template get(final TemplateSource source, final Parser parser) {
return cache.get(source, parseTemplate(parser));
}

/**
* This method does nothing on Caffeine. Better option is to use a loading cache with a
* eviction policy of your choice.
* This method does nothing on Caffeine. Better option is to use a loading cache with a eviction
* policy of your choice.
*
* Don't use this method.
* <p>Don't use this method.
*
* @param reload Ignored.
* @return This template cache.
*/
@Override public TemplateCache setReload(final boolean reload) {
@Override
public TemplateCache setReload(final boolean reload) {
// NOOP
return this;
}
Expand Down
Loading