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:
- If
hooks.pydoes not exist, creates it with the standard framework imports. - Appends a function stub for
<function_name>. - Appends a
register_template_hook("<slot>", <function_name>)call. - Updates
[tool.splent.contract.provides].hooksinpyproject.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
@versionsuffix). 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
feature:hooks— list current hooksfeature:hook:remove— remove a hook- Template system — hook slot naming conventions