Base class: Part

Fragment is a class used to build small HTML fragments that plug into iommis structure.

h1 = Fragment(children__text='Tony', tag='h1')

It’s easiest to use via the html builder:

h1 = html.h1('Tony')

Fragments are useful because attrs, template and tag are evaluated, so if you have a Page with a fragment in it you can configure it later:

class MyPage(Page):
    header = html.h1(
            lambda request, **_: request.user.is_staff,

Rendering a MyPage will result in a <h1>, but if you do MyPage(parts__header__tag='h2') it will be rendered with a <h2>.

Refinable members

  • after
    Type: Union[int, str]
  • assets
    Type: Namespace
  • attrs
    Type: Attrs
  • endpoints
    Type: Namespace
  • extra
    Type: Dict[str, Any]
  • extra_evaluated
    Type: Dict[str, Any]
  • include
    Type: bool
  • iommi_style
    Type: str
  • tag
  • template
    Type: Union[str, iommi._web_compat.Template]