restish.templating

Templating support.

class restish.templating.Rendering

Bases: object

args(request)
Return a dict of args that should always be present.
element(template)

Decorator that renders the returned dict of args using the template by calling render(request, template, args).

The decorated method’s first argument must be a http.Request instance. All arguments (including the request) are passed on as-is.

The decorated method must return a dict that will be passed to the render(request, template, args) function.

Parameters:
  • template – Name of the template file.
  • content_type – Optional content type, defaults to ‘text/html’
element_args(request, element)
Return a dict of args that should be present when rendering elements.
page(template, content_type='text/html; charset=utf-8')

Decorator that returns an HTTP response by rendering the returned dict of args using the template by calling render(request, template, args).

The decorated method’s first argument must be a http.Request instance. All arguments (including the request) are passed on as-is.

The decorated method must return a dict that will be passed to the render(request, template, args) function.

Parameters:
  • template – Name of the template file.
  • content_type – Optional content type, defaults to ‘text/html’
page_args(request, page)
Return a dict of args that should be present when rendering pages.
render(request, template, args={})

Render the template and args using the configured templating engine.

Parameters:
  • request – Request instance.
  • template – Name of the template file.
  • args – Dictionary of args to pass to the template renderer.

This Page

Quick search