Skip to content

Templates that read like the page they render.

Looma brings Laravel Blade's syntax to Spring Boot. Write HTML with {{ }} and @directives, and get layouts, components, validation errors and CSRF without attributes bolted onto your markup. Drop-in for a Spring MVC controller, with a sandboxed expression language and a startup check that refuses to boot on a broken template.

Latest version on Maven Central Build status Apache 2.0 license Open source, tested on Java 21 and 25 with Spring Boot 3.3 to 4.0.
Looma
@extends('layouts.app')

@section('content')
  <h1>Hello, {{ $user.name }}!</h1>

  @forelse($posts as $post)
    <li @class({'first': $loop->first})>
      {{ $post.title }}
    </li>
  @empty
    <li>No posts yet</li>
  @endforelse

  <form method="post" action="/posts">
    @csrf
    <input @field('title')>
    @error('title')<small>{{ $message }}</small>@enderror
  </form>
@endsection
Thymeleaf
<html layout:decorate="~{layouts/app}">
<div layout:fragment="content">
  <h1 th:text="|Hello, ${user.name}!|"></h1>

  <th:block th:if="${!posts.isEmpty()}">
    <li th:each="post, s : ${posts}"
        th:classappend="${s.first} ? 'first'"
        th:text="${post.title}"></li>
  </th:block>
  <li th:if="${posts.isEmpty()}">No posts yet</li>

  <form method="post" th:action="@{/posts}"
        th:object="${form}">
    <input th:field="*{title}">
    <small th:if="${#fields.hasErrors('title')}"
           th:errors="*{title}"></small>
  </form>
</div>
4× to 9× less CPU than Thymeleaf for the same pages, from a simple list to a heavy dashboard. Benchmarks
Fails at startup on a syntax error or a missing layout, include or component, with file and line.
Sandboxed expressions: no T(), constructors, reflection or bean access unless you opt in.
Java 21 and 25 × Spring Boot 3.3 to 4.0, including Spring Security, tested on every push.

How a page is rendered

Four steps, from the template you write to the HTML your visitor gets. Click a step, or let it play.

<h1>Hello, {{ $user.name }}!</h1>
<ul>
@foreach($posts as $post)
  <li>{{ $post.title }}</li>
@endforeach
</ul>
A template is HTML with gaps. {{ }} prints a value, escaped for HTML. Directives such as @foreach and @if control the page. The HTML around them stays exactly as you wrote it.
<h1>Hello, {{ $user.name }}!</h1>
<ul>
@foreach($posts as $post)
  <li>{{ $post.title }}</li>
@endforeach
</ul>
Parsed once, then cached. Plain HTML becomes ready-made text. Only the expressions and directives are left for each request. A syntax error stops the app at startup, with the file and line.
@GetMapping("/")
String home(Model model) {
    model.addAttribute("user", new User("Ada"));
    model.addAttribute("posts", List.of(
            new Post("Hello Looma"),
            new Post("Layouts and components")));
    return "home";   // templates/home.looma.html
}
Plain Spring MVC. Model attributes become $user and $posts in the template. Records, getters and maps all work, and so do the request, the signed-in user and validation errors.
<h1>Hello, Ada!</h1>
<ul>
  <li>Hello Looma</li>
  <li>Layouts and components</li>
</ul>
Copy the text, fill the gaps. The prepared HTML is copied as it is and each gap gets its value. Thymeleaf walks every tag on every request instead, which is why the same page costs Looma 4 to 9 times less CPU. See the benchmarks

Install

One dependency. Templates go in src/main/resources/templates/ as *.looma.html and controllers return the view name as usual.

<dependency>
  <groupId>io.github.djamelkorei</groupId>
  <artifactId>looma-spring-boot-starter</artifactId>
  <version>0.1.3</version>
</dependency>
implementation("io.github.djamelkorei:looma-spring-boot-starter:0.1.3")

What you get

  • Layouts, components, slots and stacks


    @extends / @section inheritance, <x-alert> components with @props and named slots, @push into the layout's <head>, @once for a component's styles. No layout dialect to add.

    Template syntax

  • Forms that know Spring


    @bind and @field fill name, id and value from the model object, keep the rejected input after a failed @Valid submit, and @error shows the message from your MessageSource.

    Form binding

  • Safe by default


    Escaped output, a sandboxed SpEL subset, bounded loops and recursion, buffered output so an error never sends half a page, and @auth / @can that fail closed.

    Security & operations

  • Built to be extended


    Every directive is one small class behind a public API. Yours are plain Spring beans; so are template helpers and the beans you expose with @TemplateAccessible.

    Extending & architecture

Start here

  1. Install it: one dependency, no other setup.
  2. Getting started: a page, a layout, a validated form and a component in ten minutes.
  3. Migrating from Thymeleaf: the th:* to Looma mapping, and how to run both engines while you move.

Looma is open source under the Apache License 2.0 and lives on GitHub.