betty.render module - Betty documentation

Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# betty.render module

Provide the Render API.

class betty.render.Renderer

  Bases: `object`

  Define a (file) content renderer.

  Renderers can be implemented for a variety of purposes: - invoking templating engines - file conversions

  property file_extensions: set[str]

    The extensions of the files this renderer can render.

  async render_file(file_path: pathlib.Path, *, job_context: betty.job.Context | None = None, localizer: betty.locale.Localizer | None = None) → pathlib.Path

    Render a single file.

    Return type:

      `pathlib.Path`

    Returns:

      The file’s new path, which may have been changed, e.g. a renderer-specific extension may have been stripped from the end.

    Parameters:

      - file_path (`pathlib.Path`)

      - job_context (`betty.job.Context` | `None`)

      - localizer (`betty.locale.Localizer` | `None`)

class betty.render.SequentialRenderer

  Bases: `Renderer`

  Render using a sequence of other renderers.

  Parameters:

    renderers (`list`[`betty.render.Renderer`])

  __init__(renderers: list[betty.render.Renderer])
    Parameters:

      renderers (`list`[`betty.render.Renderer`])

  property file_extensions: set[str]

    The extensions of the files this renderer can render.

  async render_file(file_path: pathlib.Path, *, job_context: betty.job.Context | None = None, localizer: betty.locale.Localizer | None = None) → pathlib.Path

    Render a single file.

    Return type:

      `pathlib.Path`

    Returns:

      The file’s new path, which may have been changed, e.g. a renderer-specific extension may have been stripped from the end.

    Parameters:

      - file_path (`pathlib.Path`)

      - job_context (`betty.job.Context` | `None`)

      - localizer (`betty.locale.Localizer` | `None`)