Fragment
========
Base class: :doc:`Part`
`Fragment` is a class used to build small HTML fragments that plug into iommi's structure.
.. code-block:: python
h1 = Fragment(children__text='Tony', tag='h1')
It's easiest to use via the html builder:
.. code-block:: python
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:
.. code-block:: python
class MyPage(Page):
header = html.h1(
'Hi!',
attrs__class__staff=
lambda request, **_: request.user.is_staff,
)
Rendering a `MyPage` will result in a `
`, but if you do
`MyPage(parts__header__tag='h2')` it will be rendered with a ``.
Refinable members
-----------------
* `after` (:ref:`evaluated `)
Type: `Union[int, str]`
* `assets`
Type: `Namespace`
* `attrs` (:ref:`evaluated `)
Type: :doc:`Attrs`
* `children`
* `endpoints`
Type: `Namespace`
* `extra`
Type: `Dict[str, Any]`
* `extra_evaluated`
Type: `Dict[str, Any]`
* `extra_params`
* `include` (:ref:`evaluated `)
Type: `bool`
* `iommi_style`
Type: `str`
* `tag` (:ref:`evaluated `)
* `template` (:ref:`evaluated `)
Type: `Union[str, iommi._web_compat.Template]`
Methods
-------
`on_bind`
^^^^^^^^^
`on_refine_done`
^^^^^^^^^^^^^^^^
`own_evaluate_parameters`
^^^^^^^^^^^^^^^^^^^^^^^^^
`render_text_or_children`
^^^^^^^^^^^^^^^^^^^^^^^^^