0

sitegui.dev · 1mo · discuss

I've refactored this blog and some other web apps in Rust that I maintain from Jinja templates to a type-safe Rust macro. To illustrate the difference, let's start with a concrete Jinja template example: <style> .comment { border-left: thin var(--secondary-bg) solid; padding-left: 10px; } </style> <div class="comment"> <p> <strong>{{ name }}</strong> {% if site %} (<a href="https://{{ site }}" target="_blank">{{ site }}</a>) {% endif %} </p> {{ html_content | safe }} </div> This Jinja template uses variable replacement with {{ ... }}, control flow with {% if ... %}...{% endif %} and some kind of functional transformation (called "filters") with...