--- id: pybars3 version: "0.9.7" license: unclear license_treatment: copyleft maintenance: dormant --- # pybars3 — Handlebars.js templating for Python 3 and 2 License: copyleft · Maintenance: dormant · Downloads: 355.5K/mo ## 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 above — 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 pip install pybars3 uv add pybars3 poetry add pybars3 ## Installing 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: unspecified - Install friction: high - Maintenance: dormant - Downloads: 355.5K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags handlebars template engine python, handlebars.js python implementation, template rendering python, shared templates server client, mustache alternative python, handlebars compiler python, template-engine, handlebars, dormant [View on SkillFed](https://skillfed.io/packages/pybars3) · [View on PyPI](https://pypi.org/project/pybars3/)