PyBars4: Handlebars.js templating for Python 3

0.9.13 · active · verified Thu Apr 16

PyBars4 is a Python 3 implementation of the popular Handlebars.js templating language. It allows developers to compile and render Handlebars templates within Python applications. The library is currently at version 0.9.13 and has an active, though somewhat sporadic, release cadence with recent updates focusing on bug fixes and changes to HTML escaping behavior.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates compiling a basic Handlebars template and rendering it with a Python dictionary context.

from pybars import Compiler

compiler = Compiler()
source = u"Hello {{name}}!"
template = compiler.compile(source)

context = {'name': "World"}
result = template(context)

print(result) # Expected: Hello World!

view raw JSON →