feature:hook:add

Add a new template hook registration to a feature’s hooks.py.


Usage

splent feature:hook:add <feature_ref> <slot> <function_name>

Arguments

Argument Description
<feature_ref> Editable feature: splent_feature_notes or splent-io/splent_feature_notes
<slot> Hook slot name, e.g. layout.sidebar or nav.top_links
<function_name> Python function name for the hook callback, e.g. render_notes_sidebar

Example

splent feature:hook:add splent_feature_notes layout.sidebar render_notes_sidebar

Description

This command:

  1. If hooks.py does not exist, creates it with the standard framework imports.
  2. Appends a function stub for <function_name>.
  3. Appends a register_template_hook("<slot>", <function_name>) call.
  4. Updates [tool.splent.contract.provides].hooks in pyproject.toml.

The generated stub in hooks.py:

def render_notes_sidebar():
    return ""  # TODO: render your hook fragment here


register_template_hook("layout.sidebar", render_notes_sidebar)

Replace the stub body with a render_template(...) call or any HTML string.


Requirements

  • The feature must be editable (no @version suffix). Versioned snapshots are immutable.
  • The slot name must not already be registered in hooks.py.
  • The function name must not already be used in hooks.py.

See also


Back to top

splent. Distributed by an LGPL license v3. Contact us: drorganvidez@us.es