Introduction
Carrot is a modern, designer-friendly template engine for Java. It is based on Jinja2, and while originally a fork of Jangod, has since been completely rewritten.
Fast and customizable, you can register custom tags for highly specialized rendering, you can register Java objects and methods for custom formatting, and you can use template inheritance for maintain common layout and styles.
Originally designed for HTML rendering, Carrot can be used for any for textual rendering, including CSS, Javascript, or any other text files.
Sample
{% extends "skeleton.html" %}
{% block "content" %}
<ul>
{% for account in accounts %}
<li>
<a href="/accounts/{{ account.id }}">
{{ empires[account.empire_id].name }}
</a>
</li>
{% endfor %}
</ul>
{% end %}
Features
- Automatic HTML escaping (which can be overridden, of course)
- Template inheritance
- Powerful object querying syntax (for calling methods on data bound objects, querying maps and sub-objects, etc)
- Easy debugging, with verbose error messages and exception
- Highly configuration, with the ability to write your own functions and tags