Chat.template_data — alfred3_interact

Skip to main content
`Ctrl`+`K`

# Chat.template_data

property Chat.template_data: dict

  Dictionary of data to be passed on to jinja templates.

  When deriving a new element class, you will often want to redefine this property to add template data. When doing so, remember to retrieve the basic template data with `super()`:

      import alfred3 as al

      class NewElement(al.Element):

          @property
          def template_data(self):
              d = super().template_data
              d["my_value"] = "this is my value"

              return d    # don't forget to return the dictionary!

  The call `super().template_data` applies the parent classes code to the current object. That way, you only need to define values that differ from the parent class.

  Note

  Be aware that, by default, the same template data will be passed to `element_template` and `base_template`.

  Type

    dict