Tempered


I focused strongly on performance, aiming to beat Jinja2 and Django, which is something I succeeded on.

Benchmark

Syntax

Originally I had designed the project to use a syntax similar to Jinja2

{% param text: str %}
{% param href: str | None = None %}

{% block A %}
    {% if href %}
        <a href="{{href}}"> {{text}} </a>
    {% else %}
        <span> {{text}} </span>
    {% endif %}
{% endblock %}

The problem I eventually had with syntax is it required custom tooling to work. It most autoformatters broke it and linters complained.

I eventually swapped to a HTML complaint syntax:

<script type="tempered/metadata">
parameters:
    text:
        type: str
    href:
        type: str | None
        default: None
</script>

<t:block name="a">
    <t:if cond="href">
        <a href="{{href}}"> {{text}} </a>
    </t:if>
    <t:else>
        <span> {{text}} </span>
    </t:else>
</t:block>

This meant that no custom tooling was required to work with templates, anything HTML would work. It almost I could

Type Intergration

generation