pybars3
Handlebars.js templating for Python 3 and 2
What it is and what it does
Pybars3 is a Python implementation of the Handlebars.js templating language, designed to let you write templates once and use them on both server and client. It compiles Handlebars syntax into Python callables that render templates with data and custom helpers. The package supports a substantial subset of Handlebars features including block helpers, partials, dynamic partials, subexpressions, and scope accessors like @index and @root.
The library works by parsing template source into an abstract syntax tree, then generating Python code that renders the template. Helpers are Python functions that accept context and options; partials are pre-compiled template fragments. The package uses a strlist class (a list subclass with a __unicode__ method) to avoid quadratic string concatenation overhead during rendering. It is maintained pragmatically for server-client template sharing rather than as a comprehensive Handlebars port, so not all Handlebars 2.0 features are implemented.
Use it for:
- Share template definitions between a Python backend and a JavaScript frontend without rewriting them.
- Render server-side HTML using Handlebars syntax when you prefer it over Jinja2 or other Python templating languages.
- Build custom template helpers in Python that integrate with Handlebars block syntax and context passing.
- Precompile Handlebars templates on the server for distribution to client-side rendering.
- Migrate from a Node.js Handlebars setup to Python while keeping template syntax consistent.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Pybars3 compiles and renders Handlebars.js templates in Python, allowing you to use the same template syntax on both server and client.
No—install friction is high (source-only distribution), maintenance is dormant (last release 2019-11-05), and Python version support is outdated (classifiers only list up to 3.4). The copyleft license also restricts proprietary modifications. Consider only if you have an existing codebase already using pybars3 or a specific requirement to share Handlebars templates with a legacy system.
Install
pybars3 on PyPI
pip
pip install pybars3uv
uv add pybars3poetry
poetry add pybars3Installing pybars3
Before you install
High install friction due to source-only distribution (pybars3-0.9.7.tar.gz). Maintenance is dormant—last release was 2019-11-05, over 2474 days ago, though the repository remains active with a recent commit on 2024-07-09.
License in practice
Licensed under GNU Lesser General Public License version 3 (copyleft). Any derivative work or modification must be distributed under the same license; proprietary use of modifications is restricted.
Quickstart
from pybars import Compiler
compiler = Compiler()
source = u"{{#list people}}{{firstName}} {{lastName}}{{/list}}"
template = compiler.compile(source)
def _list(this, options, items):
result = [u'']
for thing in items:
result.extend(options['fn'](thing))
return result
output = template(
{'people': [{'firstName': 'John', 'lastName': 'Doe'}]},
helpers={'list': _list}
)
Requires PyMeta3 as a runtime dependency; source distribution requires a build environment.
Verify before relying
- Whether PyMeta3 is reliably available and maintained for modern Python versions.
- Current compatibility with Python versions beyond 3.4 (classifiers list only up to 3.4).
- Whether all Handlebars 2.0 features are fully implemented or if gaps remain as noted in the description.
Package facts
| License | not declared (copyleft) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | dormant — 2,474 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 355,539/month — #7,289 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pybars3-0.9.7.tar.gz
Tags
More Markup packages
PyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
markdown-it-pyA Python markdown parser that converts markdown…
permissive · top 100 on PyPI
beautifulsoup4Beautiful Soup parses HTML and XML documents…
permissive · top 100 on PyPI
et-xmlfileet_xmlfile writes large XML files with minimal…
permissive · top 1,000 on PyPI
tomlkitParses and edits TOML files while preserving…
permissive · top 1,000 on PyPI
docstring-parserParses Python docstrings in ReST, Google,…
permissive · top 1,000 on PyPI
pybars4Pybars4 compiles and renders Handlebars.js…
copyleft · top 15,000 on PyPI
stylusBridges Python code to the Stylus CSS compiler,…
permissive · top 15,000 on PyPI
pydantic-handlebarsRenders Handlebars templates for composing LLM…
permissive · top 5,000 on PyPI
chevronChevron renders Mustache templates in Python,…
permissive · top 5,000 on PyPI
jinja_partialsAdds a `render_partial()` function to Jinja2…
permissive · top 5,000 on PyPI
django-template-partialsProvides reusable named template partials for…
permissive · top 15,000 on PyPI
MakoMako compiles Python-embedded templates into…
permissive · top 1,000 on PyPI
djlintdjlint formats and lints HTML templates with…
copyleft · top 5,000 on PyPI
pystachePystache renders Mustache templates—a…
permissive · top 5,000 on PyPI
lacesLaces provides Django components that bundle…
permissive · top 5,000 on PyPI