chevron-blue
raw JSON → 0.3.0 verified Fri May 01 auth: no python
A Python implementation of the Mustache template language, fork of chevron with fixes and updates. Current version 0.3.0, requires Python >=3.8. Released occasionally, not aggressively maintained.
pip install chevron-blue Common errors
error ModuleNotFoundError: No module named 'chevron_blue' ↓
cause Trying to import the package as 'chevron_blue' (with underscore) instead of 'chevron'.
fix
Use 'import chevron' (without underscore). The package name on PyPI is chevron-blue, but the module name is chevron.
error ImportError: cannot import name 'render' from 'chevron' ↓
cause Possibly installed the original chevron instead of chevron-blue, or using a very old version.
fix
Uninstall chevron and install chevron-blue: pip uninstall chevron && pip install chevron-blue. Then import chevron and use chevron.render.
Warnings
gotcha The import is 'chevron' not 'chevron_blue'. The library is installed as chevron-blue but module name is chevron. Many users try 'from chevron_blue import ...' which fails. ↓
fix Use 'import chevron'
deprecated chevron-blue is a fork of chevron. The original chevron library is incompatible with chevron-blue's API. Do not mix the two. ↓
fix Uninstall chevron if installed and use only chevron-blue.
gotcha chevron.render() expects a string or file-like object for the template. Passing a file path as a string will silently fail to open the file; it will treat the path as the template text. ↓
fix Use chevron.render(template=open('file.mustache'), data=context) or read the file first.
Imports
- chevron wrong
from chevron_blue import ...correctimport chevron
Quickstart
import chevron
template = "Hello, {{name}}!"
context = {"name": "World"}
result = chevron.render(template, context)
print(result) # Hello, World!