Template

class dasha.web.templates.Template(parent=None)[source]

Bases: dasha.web.templates.IdTree, tollan.utils.namespace.NamespaceMixin

An abstract class that defines an encapsulated entity around a functional group of dash components and the callbacks.

One can do arbitrary nesting of templates through the child factory function, which returns a child template instance.

Attributes Summary

layout

Implement this to return a valid Dash layout object.

Methods Summary

after_setup_layout(self, app)

Hook that run after the setup_layout function call.

before_setup_layout(self, app)

Hook that run before the setup_layout function call.

child(self, factory, \*args, \*\*kwargs)

Return a child template object.`.

clear_registry()

Reset the template subclass registry.

from_dict(d, \*\*kwargs)

Return a template instance specified by dict d.

setup_layout(self, app)

Implement this to declare layout components and their callbacks.

Attributes Documentation

layout

Implement this to return a valid Dash layout object.

Methods Documentation

after_setup_layout(self, app)[source]

Hook that run after the setup_layout function call.

before_setup_layout(self, app)[source]

Hook that run before the setup_layout function call.

child(self, factory, \*args, \*\*kwargs)[source]

Return a child template object.`.

The actual creation of the object is delegated to the appropriate subclass based on the type of factory:

1. factory is a Template instance. The instance is added as-is as the child of this object. ValueError is raised if args or kwargs are set.

2. factory is a Dash component class, (e.g., Div). A ComponentTemplate object is created and returned. args and kwargs are passed to the constructor.

3. factory is a Dash component instance. The instance is wrapped in a ComponentWrapper object and returned. ValueError is raised if args or kwargs are set.

ValueError is raised if factory does not conform to the cases listed above.

classmethod clear_registry()[source]

Reset the template subclass registry.

This is useful to make fresh reload of the flask instance.

classmethod from_dict(d, \*\*kwargs)[source]

Return a template instance specified by dict d.

ValueError is raised if “template” is not in d.

abstract setup_layout(self, app)[source]

Implement this to declare layout components and their callbacks.