Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
96 lines (77 sloc) 3.14 KB

Sketchbook |version|

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

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

Features

  • Super Simple Syntax: The syntax of Sketchbook is super easy to learn. It mixes the Python syntax with the ERB style tag marker while keeping a big picture from Python.
  • Safe: The output is escaped by default unless manually overridden.
  • Unicode Support: Unicode is baked into the whole system, never worry about dealing with the bytestring.
  • Fully async/await ready: Sketchbook is designed from the ground up for and async/await syntax. Developers are able to use async for, async with and await fearlessly.
  • Fast Execution: Like Mako and Jinja2, Sketchbook compiles the template into Python bytecode before execution, it should be as fast as running other Python code.
  • Dynamic Template Inheritance and Including: The template can inherit from and include the other templates at the runtime, which significantly improves 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's quite a few template engines for Python, why reinvent the wheel?

  • Most template engines are relics from Python 2.x, thus they suck when dealing with unicode.
  • The coroutine is now one of the first class citizens 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

.. toctree::
   :maxdepth: 3

   integration
   language
   sketchbook

Indices and tables