Sketchbook 0.3.1.dev40

<% async for blank_page in sketchbook %>
    <% let sketch = await blank_page.draw() %>
<% end %>

Sketchbook is a templating engine designed for asyncio. It takes advantage of Python 3’s unicode and async/await syntax(PEP 492) written for asyncio (PEP 3156) and concurrent I/O with a syntax inspired by ERB and Django Templates.

Features

  • Simple Syntax: The syntax of Sketchbook is easy to learn. It mixes the Python syntax with the ERB style tag marker.

  • Safe: The output is escaped by default unless manually overridden.

  • Unicode Support: Unicode is used by default. No need to worry about Python2 bytestring.

  • async/await ready: Sketchbook is designed to use with async/await syntax. Developer can use async/await syntax to the full extent.

  • Fast Execution: Just like Mako and Jinja2, Sketchbook compiles sketches into Python bytecode before execution, allowing it to be executed as fast as other Python code.

  • Dynamic Template Inheritance and Inclusion: Sketches can inherit from and include the other sketches at the runtime, which significantly improve the reusability and flexibility.

Intallation

$ pip install -U sketchbook

Source Code

sketchbook is open sourced under Apache License 2.0 and its source code is hosted on GitHub.

Alternative Event Loop

Beside the asyncio module from the Python standard library, Sketchbook can also be used with curio.

Requirements

Usage

Why?

There are quite a few template engines for Python, why reinvent the wheel?

  • Most template engines are relics from Python 2.x hence they suck when dealing with unicode.

  • Coroutine is now one of a first class feature in the Python language, but not in these template engines.

  • None of them support the new type hints system introduced in Python 3.5.

  • It’s fun!

See also

Indices and tables