{"id":1415,"library":"chevron","title":"Chevron Mustache Templating","description":"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.","status":"active","version":"0.14.0","language":"en","source_language":"en","source_url":"https://github.com/noahmorrison/chevron","tags":["templating","mustache","html","text-generation"],"install":[{"cmd":"pip install chevron","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"render","correct":"import chevron\noutput = chevron.render(template=..., data=...)"}],"quickstart":{"code":"import chevron\n\ntemplate_string = 'Hello, {{name}}! You are {{age}} years old.'\ndata_context = {'name': 'World', 'age': 42}\n\nrendered_output = chevron.render(template=template_string, data=data_context)\nprint(rendered_output)\n\n# Example with a list and conditional section\ntemplate_list = 'Users:\\n{{#users}}- {{name}} (ID: {{id}})\\n{{/users}}'\ndata_list = {'users': [{'name': 'Alice', 'id': 1}, {'name': 'Bob', 'id': 2}] }\nrendered_list = chevron.render(template=template_list, data=data_list)\nprint(rendered_list)","lang":"python","description":"Render a Mustache template string with provided data. Chevron handles basic variables, sections, and lists according to the Mustache specification."},"warnings":[{"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.","message":"Python 2 support was dropped in Chevron version 0.13.0. Attempts to use chevron on Python 2.x environments will result in errors.","severity":"breaking","affected_versions":">=0.13.0"},{"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.","message":"The 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.","severity":"breaking","affected_versions":">=0.11.0"},{"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()`.","message":"Mustache'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`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}