Registry / web-framework / chevron

chevron

JSON →
library0.14.0pypypi✓ verified 30d ago

Chevron is a lightweight, pure-Python implementation of the Mustache templating language. It provides a simple API for rendering templates using dictionaries or objects as data contexts. It adheres closely to the Mustache specification. The current version is 0.14.0, and it generally follows an as-needed release cadence for bug fixes and minor improvements, with long periods of stability.

pip install chevron
INSTALL
IMPORT
SIG · CHEVRON
C
chevron
web-frameworkpythonv0.14.0
Install
1.5s avg
Import
—
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.14.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

render
✓ from chevron import render
✗ import chevron

Render a Mustache template string with provided data. Chevron handles basic variables, sections, and lists according to the Mustache specification.

import chevron template_string = 'Hello, {{name}}! You are {{age}} years old.' data_context = {'name': 'World', 'age': 42} rendered_output = chevron.render(template=template_string, data=data_context) print(rendered_output) # Example with a list and conditional section template_list = 'Users:\n{{#users}}- {{name}} (ID: {{id}})\n{{/users}}' data_list = {'users': [{'name': 'Alice', 'id': 1}, {'name': 'Bob', 'id': 2}] } rendered_list = chevron.render(template=template_list, data=data_list) print(rendered_list)
chevron --version
Debug
Known issues
breakingPython 2 support was dropped in Chevron version 0.13.0. Attempts to use chevron on Python 2.x environments will result in errors.
fix
Upgrade to Python 3.6+ to use Chevron 0.13.0 or newer. For Python 2 compatibility, you would need to pin chevron to <0.13.0, though this is not recommended due to Python 2's end-of-life.
affects: >=0.13.0
breakingThe mechanism for resolving partials changed significantly in version 0.11.0. The `path` parameter for specifying partial locations was renamed to `partials_path` and partials are now resolved via a template loader.
fix
If upgrading from <0.11.0 and using partials, ensure you update your `render` calls to use `partials_path` and verify that your partials are correctly located and resolved by the new loader mechanism. Consult the documentation for the `partials_path` parameter.
affects: >=0.11.0
gotchaMustache's definition of 'falsy' for sections (e.g., `{{#section}}`) differs from Python's default behavior. In Mustache, `0` (the number zero) is considered 'truthy' for sections, while an empty list `[]` is 'falsy'. This can be counter-intuitive for Python developers used to `bool(0)` being `False`.
fix
Be aware of Mustache's truthiness rules for sections when preparing your data context. If you need a section not to render when a value is `0`, you might need to transform your data (e.g., replace `0` with `None` or an empty string) before passing it to `chevron.render()`.
affects: All versions
Upgrade
Version history
0.14.0latest on PyPI · released Jan 2, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
21 hits · last 30 days
node
18
OpenAI (training)
1
Resources
chevron — pip install chevron · libregistry