chevron

A fast, spec-compliant Python implementation of the Mustache templating language.

Library
PyPI
v0.14.0
555stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
36/100Needs Attention
Development Activity0
Maintenance0
Community64
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture80
Code Quality78
Innovation74
Learning Curve90

chevron is a Python renderer for Mustache, the popular logic-less templating language. You give it a template string (or file) containing {{tags}} and a dictionary of data, and it produces the rendered output — substituting variables, expanding sections and inverted sections, pulling in partials, and running lambdas, all according to the Mustache spec.

Its design goal is speed and correctness: chevron passes the official Mustache spec test suite and runs substantially faster than older Python implementations like pystache. Being logic-less keeps templates simple and safe, which makes chevron a common choice for generating emails, config files, code, HTML fragments, and other text where you want a clean separation between data and presentation.

What You Get

  • A single render() function that turns a template plus data into a string
  • Full Mustache spec support: variables, sections, inverted sections, partials, lambdas, and delimiters
  • A fast, single-pass tokenizer and renderer
  • Optional command-line usage for rendering template files
  • HTML escaping by default with an unescaped triple-mustache option

Common Use Cases

  • Generating transactional emails from templates and data
  • Rendering config files or infrastructure manifests from a data model
  • Producing HTML fragments or static pages without a full template engine
  • Code and text generation where logic-less templates keep output predictable

Under The Hood

Architecture — The package splits cleanly into tokenizer.py, which scans a template into a stream of typed tokens (literals, variables, section open/close, partials, delimiter changes), and renderer.py, which walks that stream against a stack of data scopes to emit the output string. main.py provides the CLI entry point (chevron=chevron:cli_main) and metadata.py holds version info. Section handling manages context scoping and lambda invocation as it recurses.

Tech Stack — Pure Python with no runtime dependencies, packaged via setup.py/setuptools and tested across a wide range of Python versions using tox.

Code Quality — Strong for its size: it runs against the official Mustache spec test suite (test_spec.py plus the spec/ submodule), maintains flake8/pep8 compliance, tracks coverage, and includes a benchmark.py for performance comparisons. Development activity has slowed, but the code is stable and mature.

API Design — Minimal and intuitive: chevron.render(template, data) covers the common case in one call, with keyword arguments for partials and configuration. Because Mustache is logic-less, there is very little API surface to learn.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search