Vascula v1.0.1 GitHub

v1.0.1 · MIT · no dependencies

Safe, fast HTML templates for Go

Vascula is a template language for HTML. You write markup with {{ output }} and {% tags %}; an application compiles the template once and renders it with data.

go get vascula.dev/vascula@latest
Template
<h1>{{ settings.title }}</h1>
{% if settings.items.size > 0 %}
  <ul>{% for item in settings.items %}<li>{{ item | upcase }}</li>{% endfor %}</ul>
{% else %}
  <p>Nothing yet.</p>
{% endif %}
Data
{"settings": {"title": "Tea & coffee", "items": ["sencha", "<b>espresso</b>"]}}
Output
<h1>Tea &amp; coffee</h1>

  <ul><li>SENCHA</li><li>&lt;B&gt;ESPRESSO&lt;/B&gt;</li></ul>

The output is escaped for HTML automatically, so the & and the markup inside the data cannot break the page.

Pixel-art greenhouse at night: glowing green vines connect a developer at a desk to products, a shop front, carts and parcels.

What makes it different

01

Safe by default

Everything you print is HTML-escaped. There is no raw filter and no way for a template to switch escaping off; only the application can hand over trusted HTML. JSON printed inside an HTML attribute is escaped for that position too, and a link or other URL with printed parts cannot be a javascript: URL.

02

Explicit about data

A template can only read the data roots the application allows. Reading anything else is an error, not a silent blank, and the application can list every name a template reads before it ever renders.

03

Bounded

Compilation and rendering have limits on source size, nesting, work, output and value size. A template cannot loop forever or build a gigabyte string.

04

Fast

A 48-product grid renders in about 120 microseconds, more than twice as fast as the popular Liquid implementations in Go and Ruby. See Performance.

05

Familiar

The syntax will look familiar if you know Liquid or Jinja, but Vascula is its own language with documented behavior. See Coming from Liquid.

Benchmarks

Microseconds per render, lower is better. How it was measured

Product grid, 48 products

Vascula122 µs
Go Liquid320 µs
Ruby Liquid352 µs

where | sort | map | join over 48 products

Vascula10.4 µs
Go Liquid27 µs
Ruby Liquid37 µs

The same, products with 150 fields each

Vascula12.2 µs
Go Liquid30 µs
Ruby Liquid38 µs

Compiling the grid template

Vascula11.7 µs
Go Liquid32 µs
Ruby Liquid89 µs

Where to start

Write templates

Syntax, then the tutorial

Look up a filter or tag

Filters, Conditionals, Loops

Embed Vascula in a Go program

Getting started, then the Go API

Extend it with your own filters and tags

Extending Vascula

Understand what it protects against

Safety and limits

Generate templates with an AI agent

Vascula for agents and llms.txt

Build a theme for a Tringify store

Tringify theme docs

Made by Tringify

Vascula is made by Tringify and renders every Tringify storefront. Building a theme for a Tringify store? See the Tringify theme docs.

Versions

Vascula is at version 1 and follows semantic versioning; the changelog lists every change. See Versions and stability.

Every page of this site is also available as Markdown: add .md to the address, or read llms-full.txt for the whole site in one file.