Skip to content

jens-kaiser/freshmarker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FreshMarker

A simple, small but powerful template engine based loosely on the FreeMarker syntax. FreshMarker is implemented in Java 17 (Java 21 since version 1.0.0) and supports the java.time API and Records.

You can find a detailed description of all Freshmarker features in the manual.

The release notes contain changes to the template engine since version 1.4.6.

Some in-depth articles on Freshmarker can be found on schegge.de.

Example Benchmarks

benchmark

mustache

0.9.11

freemarker

2.3.23

velocity

1.7

thymeleaf

2.1.4.RELEASE

trimou

1.8.2.Final

freshmarker

1.6.6

Usage

<dependency>
link:pom.xml[role=include]
</dependency>

Examples

Simple Example
Configuration configuration = new Configuration();
Template template = configuration.builder().getTemplate("test", "temporal=${temporal}, path=${path.size}");
String result = template.process(Map.of("temporal", LocalTime.of(12, 30), "path", Path.of("text.pdf")));
List with loop Variable
Template template = configuration.builder().getTemplate("ancestors-loop",
    """
    <#list ancestors as ancestor with loop>
      ${loop?index}. ${ancestor.givenname} ${ancestor.surename}
    </#list>
    """);
String result = template.process(Map.of("ancestors", ancestorService.ancestorsByFamily("Kaiser")));
Partial reduction of a Template
Template template = configuration.builder().getTemplate("ancestors-loop",
    """
    <h1>$title</h1>
    <#list ancestors as ancestor with loop>
      ${loop?index}. ${ancestor.givenname} ${ancestor.surename}
    </#list>
    """);
Template reduced = template.reduce("title", "Genealogy List");
String result = reduced.process(Map.of("ancestors", ancestorService.ancestorsByFamily("Kaiser")));

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages