turbo.classes

Module Contents

Classes

ModelBroadcast

Turbo

A reference to a specific broadcast.

TurboRender

A rendered template, ready to broadcast using turbo.

Attributes

APPEND

PREPEND

REPLACE

UPDATE

REMOVE

BEFORE

AFTER

SELECTOR_CSS

SELECTOR_ID

SELECTOR_TYPES

turbo.classes.APPEND = append
turbo.classes.PREPEND = prepend
turbo.classes.REPLACE = replace
turbo.classes.UPDATE = update
turbo.classes.REMOVE = remove
turbo.classes.BEFORE = before
turbo.classes.AFTER = after
class turbo.classes.ModelBroadcast(model)
turbo.classes.SELECTOR_CSS = css
turbo.classes.SELECTOR_ID = id
turbo.classes.SELECTOR_TYPES
class turbo.classes.Turbo

A reference to a specific broadcast. Broadcast names can be provided as strings or can be generated by passing in a django instance.

Eg:

Turbo(‘broadcast_name’) Turbo(django_instance)

_init_with_str(self, stream_name='')
Parameters

stream_name (str) –

_init_with_model(self, stream_target)
Parameters

stream_target (django.db.models.Model) –

update_stream_name(self)
render(self, template_name, context=None)

Returns a TurboRender object from a django template. This rendered template can then be broadcast to subscribers with the TurboRender actions (eg: append, update, etc…)

Takes a template name and context identical to Django’s render() method.

Return type

TurboRender

render_from_string(self, rendered_template)

Returns a TurboRender object from a string.

Parameters

rendered_template (str) –

Return type

TurboRender

remove(self, selector=None, id=None)

Send a broadcast to remove an element from a turbo frame.

class turbo.classes.TurboRender(stream_name, rendered_template='')

A rendered template, ready to broadcast using turbo.

append(self, selector=None, id=None)

Add a target action to the given selector.

prepend(self, selector=None, id=None)

Add a target action to the given selector.

replace(self, selector=None, id=None)

Add a target action to the given selector.

update(self, selector=None, id=None)

Add a target action to the given selector.

remove(self, selector=None, id=None)

Add a target action to the given selector.

before(self, selector=None, id=None)

Add a target action to the given selector.

after(self, selector=None, id=None)

Add a target action to the given selector.

_add_target(self, selector, id, action)
_render_frame(self, selector_type, selector, action)
Return type

str

_broadcast(self, rendered_frame)