duck.etc.internals.template

Module containing Duck’s internal template engine.

Module Contents

Classes

InternalJinja2Engine

InternalJinja2TemplateEngine class representing duck’s internal template engine, meaning this engine is focused only on retreiving templates that are within the internal Duck storage.

InternalJinja2FileSystemLoader

Functions

async_internal_render

Asynchronously render internal templates.

internal_render

Render internal templates.

API

class duck.etc.internals.template.InternalJinja2Engine(autoescape: bool = True, custom_templatetags: Optional[List[Union[duck.template.templatetags.TemplateTag, duck.template.templatetags.TemplateFilter]]] = None, environment: Optional[jinja2.Environment] = None, loader: Any = None)[source]

Bases: duck.template.environment.Jinja2Engine

InternalJinja2TemplateEngine class representing duck’s internal template engine, meaning this engine is focused only on retreiving templates that are within the internal Duck storage.

Initialization

classmethod get_default()[source]

Returns the default internal duck engine.

class duck.etc.internals.template.InternalJinja2FileSystemLoader[source]

Bases: duck.template.loaders.Jinja2FileSystemLoader

blueprint_template_dirs()[source]
global_template_dirs() List[str][source]
async duck.etc.internals.template.async_internal_render(request: duck.http.request.HttpRequest, template: str, context: Dict[Any, Any] = None, **kwargs) duck.http.response.TemplateResponse[source]

Asynchronously render internal templates.

Parameters:
  • request – The request object.

  • template – The Jinja2 template.

  • context – The context dictionary to pass to the template. Defaults to an empty dictionary.

  • **kwargs – Additional keyword arguments to parse to TemplateResponse.

Returns:

The response object with the rendered content.

Return type:

TemplateResponse

duck.etc.internals.template.internal_render(request: duck.http.request.HttpRequest, template: str, context: Dict[Any, Any] = None, **kwargs) duck.http.response.TemplateResponse[source]

Render internal templates.

Parameters:
  • request – The request object.

  • template – The Jinja2 template.

  • context – The context dictionary to pass to the template. Defaults to an empty dictionary.

  • **kwargs – Additional keyword arguments to parse to TemplateResponse.

Returns:

The response object with the rendered content.

Return type:

TemplateResponse