Skip to content

The foostache template engine for Python.

License

Notifications You must be signed in to change notification settings

ldgabbay/foostache-python

Repository files navigation

PyPI version PyPI - Python Version PyPI - License

foostache

foostache is a language and environment independent template engine.

Unlike alternatives such as Jinja2 and mustache, foostache can theoretically be implemented in any programming language for any runtime environment. The complete language specification can be found here.

This package provides a command-line utility and modules for Python 2 and 3.

Example

A template is marked-up unicode that might look like this:

{{:iterate my_array 1::2}}{{. %5.2f}}{{:before}}[{{:between}}, {{:after}}]{{:end}}

The template can be rendered given a context. The context is usually specified with a JSON value, such as:

{ "my_array": [2.6, 4, 18, 3.51, 42, 96.8] }

When the above context is applied to the above template, the following output is generated:

[ 4.00,  3.51, 96.80]

Command-Line

foostache template-file context-json-file
python -m foostache template-file context-json-file

Module

import foostache

template = foostache.Template("{{:iterate .}}{{.}}{{:end}}")
assert template.render(["a", "b", "c"]) == "abc"

About

The foostache template engine for Python.

Resources

License

Stars

Watchers

Forks

Packages

No packages published