pystache.renderengine module

Defines a class responsible for rendering logic.

class pystache.renderengine.RenderEngine(literal=None, escape=None, resolve_context=None, resolve_partial=None, to_str=None)[source]

Bases: object

Provides a render() method.

This class is meant only for internal use.

As a rule, the code in this class operates on unicode strings where possible rather than, say, strings of type str or markupsafe.Markup. This means that strings obtained from “external” sources like partials and variable tag values are immediately converted to unicode (or escaped and converted to unicode) before being operated on further. This makes maintaining, reasoning about, and testing the correctness of the code much simpler. In particular, it keeps the implementation of this class independent of the API details of one (or possibly more) unicode subclasses (e.g. markupsafe.Markup).

fetch_section_data(context, name)[source]

Fetch the value of a section as a list.

fetch_string(context, name)[source]

Get a value from the given context as a basestring instance.

render(template, context_stack, delimiters=None)[source]

Render a unicode template string, and return as unicode.

Arguments:

template: a template string of type unicode (but not a proper

subclass of unicode).

context_stack: a ContextStack instance.

pystache.renderengine.context_get(stack, name)[source]

Find and return a name from a ContextStack instance.