Feature Contracts & Hooks
Introduction
A feature’s contract says what it provides and what it requires, so the CLI can check features against each other. Hooks and registries let a feature add markup, menu entries, assets and settings to a product without editing the product’s templates.
Most of the time you only run feature:contract --write after a change, and add a hook with feature:hook:add.
splent feature:contract notes --write
splent feature:hook:add splent_feature_notes layout.authenticated_sidebar notes_sidebar
Commands and registries
| Page | What it is for |
|---|---|
feature:contract |
Infer the contract from the source code, and write it with --write |
feature:hooks |
List the template hooks a feature’s hooks.py registers |
feature:hook:add |
Add a hook registration to a feature |
feature:hook:remove |
Remove a hook registration from a feature |
feature:inject-config |
Generate a feature’s config.py from the environment variables its code reads |
feature:refine |
Set up how a feature extends another, with a wizard |
| Navigation registry | Declare an entry in the public main menu |
| Asset registry | Declare a feature’s CSS and JS for the public shell |
| Feature settings | Declare a feature’s admin-editable settings and get an admin panel for them |