Skip to content

title

title #

Title — the page's name, wherever the page is listed.

Title #

Bases: Component

The page's <title>: the browser tab, the index card, the link card.

It renders nothing into the body. Derive it from the data rather than repeating the function's name.

cg.ui.Title(f"Session {session.captured.date().isoformat()}")
Source code in capturegraph-lib/capturegraph/ui/title.py
class Title(Component):
    """The page's ``<title>``: the browser tab, the index card, the link card.

    It renders nothing into the body. Derive it from the data rather than
    repeating the function's name.

    ```python
    cg.ui.Title(f"Session {session.captured.date().isoformat()}")
    ```
    """

    text: str

    def __post_init__(self) -> None:
        """Check the prop and set the title of the page being built.

        Raises:
            RuntimeError: If no ``PageBuilder`` function is running.
        """
        super().__post_init__()
        Build.current().title = self.text

    def html(self, render: Render) -> str:
        """Nothing; the title lives in the document head."""
        return ""

__post_init__() #

Check the prop and set the title of the page being built.

Raises:

Type Description
RuntimeError

If no PageBuilder function is running.

Source code in capturegraph-lib/capturegraph/ui/title.py
def __post_init__(self) -> None:
    """Check the prop and set the title of the page being built.

    Raises:
        RuntimeError: If no ``PageBuilder`` function is running.
    """
    super().__post_init__()
    Build.current().title = self.text

html(render) #

Nothing; the title lives in the document head.

Source code in capturegraph-lib/capturegraph/ui/title.py
def html(self, render: Render) -> str:
    """Nothing; the title lives in the document head."""
    return ""