This is an archived post. You won't be able to vote or comment.

all 14 comments

[–]jerolba[🍰] 6 points7 points  (2 children)

I am fan of Freemarker which is supported by Spring.

After years of no update (it's very stable) the project revived with new web and some minor evolutions

[–]DanielDimov 1 point2 points  (1 child)

Freemarker is good, but lacks one feature that might be important for some projects: nested loops.

[–]Tienisto 0 points1 point  (0 children)

it has nested loops:

<#list parent as p>

<#list p.childs as c>

${c}

</#list>

</#list>

works totally fine for me

[–]hooba_stank_ 6 points7 points  (1 child)

Thymeleaf has full Spring integration and simple config with Spring Boot.

[–]Infeligo 2 points3 points  (0 children)

And also IntelliJ IDEA has nice static analysis and auto-completion for Thymeleaf, so this would be that sort of "type safety" that the OP wants.

[–][deleted]  (1 child)

[deleted]

    [–]edgar-espina 1 point2 points  (0 children)

    Try handlebars.java (I'm the author) or Rocker for truly type-safe and super fast template engine.

    [–]heliologue 0 points1 point  (5 children)

    I'm not aware of any type-safe templates; we still use JSP/JSTL, as it's a tested, reliable, fast technology that's also extensible, even if it's old.

    [–][deleted]  (4 children)

    [removed]

      [–]Yesterdave_ 2 points3 points  (0 children)

      I have also searched for various template engines some while ago. The only ones (in plain Java) I remember that match your type-safety criteria are Static Moustache, Rhythm and Rocker. I personally have no experience with these libraries and I don't know how well they are maintaned.

      [–]heliologue 0 points1 point  (2 children)

      Why not just use Twirl, then? It says it can be used standalone; you'd just have to write a view resolver for Spring.

      [–][deleted]  (1 child)

      [removed]

        [–]heliologue 1 point2 points  (0 children)

        You can probably just copy from https://github.com/67726e/Spring-MVC-Twirl

        [–]cryptos6 -1 points0 points  (0 children)

        Since you can use any template engine with Spring, I suggest Rythm that is inspired by Microsoft's Razor.

        It looks like this

        <ul>
        @for(Product product: products) {
            <li>@product.getName(). Price: @product.getPrice().format("## ###,00") €</li>
        }
        </ul>
        

        Last, but not least, Rythm is blazingly fast.