static_templates.renderer

class static_templates.renderer.Renderer(configuration, stdout=None)[source]

Bases: object

Renderer is used to convert a template into a static file.

__init__(configuration, stdout=None)[source]

The init function takes a row from settings.STATIC_TEMPLATES. By default, the users are required to provide a two-item tuple with the template name and the static file path.

configuration = None[source]
stdout = None[source]
log(message)[source]
render()[source]

render starts the rendering process for the given configuration.

get_template_name()[source]

Returns the template name to use when rendering to static.

get_template_context()[source]

Provides the context for render_template call.

render_template()[source]

Creates a fake request context together with the context from get_template_context and returns the rendered output.

get_static_file_path()[source]

Returns the target static file path to store the content to.

write_static_file(content)[source]

write_static_file makes sure that the target directory exists and writes the provided content to a file.

static_templates.renderer.get_renderer(path=None)[source]

Load a renderer and return the class. If a path is provided, the renderer is imported from that path. By default, static_templates.renderer.Renderer is used.