streamline.template¶
This module contains mixins and classes for working with templates.
-
streamline.template.ROCARoute¶ alias of
XHRPartialRoute
-
class
streamline.template.TemplateMixin¶ Mixin that contains methods required to render templates. This class can be used by adding template-related features to any class-based route handler.
-
get_context()¶ Returns the complete template context. This context is is a dict, and is built from the default context by augmenting it with the contents of the
bodyattribute on the route handler class.If
bodyattribute is a dict, its keys are copied to inthe context. Otherwise, a new key,'body'is added and the value of the attribute is assigned to it.
-
get_default_context()¶ Returns default context. Default behavior is to return the value of the
default_contextproperty. The property must be a dict, and it is copied before being returned so that the original remains intact.
-
get_template_func()¶ Return a template rendering function. Default behavior is to return the
template_func, which must be a callable.
-
get_template_name(template_name=None)¶ Returns template name. Default behavior is to return the value of the
template_nameproperty.If
template_nameargument is specified, it will be used instead of the property.
-
render_template()¶ Renders the template using the template name, context, and function obtained by calling the respective methods.
-
static
template_func(*args, **kwargs)¶ Get a rendered template as a string iterator. You can use a name, a filename or a template string as first parameter. Template rendering arguments can be passed as dictionaries or directly (as keyword arguments).
-
-
class
streamline.template.TemplateRoute(*args, **kwargs)¶ Class that renders the response into a template.
Subclasses: RouteBaseIncludes: TemplateMixin
-
class
streamline.template.XHRPartialRoute(*args, **kwargs)¶ Class that renders different templates depending on whether request is XHR or not.
Subclasses: TemplateRoute