Named fragment templates for page_list item rendering #36
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Currently
page_listrenders each item with a hardcoded layout: link, optional date, optional summary. There is no way to change the per-item output without modifying the directive source. This proposal adds support for named fragment templates — small.mufiles that define how each list item is rendered.Motivation
Different uses of
page_listneed different layouts:Today this requires separate directives or boolean suppression flags (
show_summary=false) that accumulate over time. A template system handles all variations with no new directive arguments.Proposed interface
```md
::page_list section=authors display_field=sort_name item_template=author-item limit=0::
```
If
item_templateis omitted, current behaviour is preserved (backward compatible).Template resolution
Fragment templates live in
system/templates/fragments/page_list/. The directive looks for<item_template>.muin that directory. If not found, falls back to the built-in default.Template context
Each item template is rendered once per matched page, with the following context keys available:
titledisplay_field(ortitleas fallback)routesummarysummaryfrontmatter valuedatedatefrontmatter valueslug<field>The link itself (
styled_theme_link(title, route)) is pre-rendered by the directive and passed as alinkcontext key, since template files cannot call Python functions directly.Default built-in template (matches current output exactly):
```
{date}
{summary}
```
Implementation sketch
directive_page_list, check foritem_templatearg (added to_RESERVED)system/templates/fragments/page_list/<name>.muviacontext["root_dir"]str.format_map()or the existing template rendering pathRelationship to other directives
The same fragment template pattern could be extended to other directives (
downloads,comments) in follow-up PRs, making it a general CMS convention rather than a one-off feature.