turbo_response.renderers#

Module Contents#

Functions#

render_turbo_stream(action[, target, content, ...])

Wraps content in correct <turbo-stream> tags.

render_turbo_frame(dom_id[, content, is_safe])

Wraps a response in correct <turbo-frame> tags.

turbo_response.renderers.render_turbo_stream(action, target=None, content='', is_safe=False, is_multiple=False)#

Wraps content in correct <turbo-stream> tags.

Parameters:
  • action (turbo_response.constants.Action) – action type

  • target (Optional[str]) – the DOM ID target of the stream or CSS selector for multiple targetss

  • content (str) – content to be wrapped. Can be empty.

  • is_safe (bool) – mark content safe for HTML escaping.

  • is_multiple (bool) – multiple targets

Returns:

<turbo-stream> string

Return type:

str

turbo_response.renderers.render_turbo_frame(dom_id, content='', is_safe=False)#

Wraps a response in correct <turbo-frame> tags.

Parameters:
  • dom_id (str) – a DOM ID present in the content

  • content (str) – content of the turbo-frame

  • is_safe (bool) – mark content safe for HTML escaping.

Returns:

<turbo-frame> string

Return type:

str