\

Show HN: Blueprint: Fast, Nunjucks-like templating engine for Java 8 and beyond

19 points - yesterday at 10:46 AM


I love the simplicity, expressibility and extendibility of Nunjucks.

But I was not able to find something with similar for Java, especially with the same syntax.

So, built one. And it's pretty fast too.

https://github.com/freakynit/Blueprint

  • TeaVMFan

    yesterday at 3:20 PM

    If you're interested in Java template engines for the client side (SPAs), you can look at Flavour: https://flavour.sourceforge.io/

    While templates are a big part of Flavour, it also includes routing, components, and idiomatic invocation of Java services.

    The book on Flavour is here: https://frequal.com/Flavour/book.html

    Example 5-letter word game single-page app made with 100% Java, 100% Flavour: https://frequal.com/wordii/

      • splix

        yesterday at 3:57 PM

        Also, for SPA with SSR take a look at Double View https://github.com/emeraldpay/double-view

        It's a React renderer that works on Java backend by using GraalVM, and then the same JS template continues to work in browser.

    • redditor98654

      today at 10:56 AM

      Interesting. I have used free marker. Pretty happy with it in general. But inability to mutate collections is an annoyance.

      I will checkout blueprint. A zero dependency library is always a bonus. I don’t see any mention of thread safety in the docs for the engine though.

        • freakynit

          today at 1:18 PM

          Hey, Blueprint rendering was already thread-safe. Only the function/filter registrations, IF done during rendering phase, was not thread-safe.

          I have just pushed small update to make even these thread-safe now. Entire library is now fully thread-safe.

          Updated README as well.

          Thanks for pointing this out.

      • susika

        yesterday at 12:57 PM

        Looks interesting. For me I settled on JTE as the go-to template engine for Java. For anyone curious: https://jte.gg @freakynit - have you seen this one before? how's it compares with Blueprint?

          • freakynit

            today at 4:47 AM

            Powerful. But I absolutely adore nunjucks syntax and how easy it is to extend it. Hence, I built Blueprint to give me that same feel in Java.

            I have used this btw, professionally :)

        • sshine

          yesterday at 1:02 PM

          Good to know.

          Normally I'd use Spring Boot and get the batteries-included experience if I ever were to make web with Java.

          But I could totally imagine needing a pure, well-made, zero-deps template engine for custom jobs.

          I certainly have similar libraries in my bookmarks for other languages, like Haskell [1] and Rust [2].

            [1]: https://hackage.haskell.org/package/heterocephalus
            [2]: https://crates.io/crates/minijinja

          • ekspreso

            yesterday at 1:38 PM

            Isn't Pebble Templates similar to this?

            https://pebbletemplates.io/

              • freakynit

                today at 6:23 AM

                Ahh... this is very very similar. I don't know why it didn't show up in Google search. Thanks for mentioning this.

            • nashashmi

              yesterday at 1:54 PM

              We never hear about Java on this forum. That makes a post like this peculiarly interesting

              • deanebarker

                yesterday at 1:25 PM

                Syntax looks very much like Liquid. I feel like that syntax is becoming a standard.

                  • whalesalad

                    yesterday at 2:23 PM

                    afaik django or jinja invented this syntax? then we saw handlebars, which is where liquid got its influence.