Skip to main content

Custom Templates

Categories (for Groups), Note Types (for Notes), and Resource Categories (for Resources) support custom HTML templates that create specialized views for different content types.

:::warning Security Notice

Custom templates execute arbitrary HTML and JavaScript. Only use them on trusted network deployments.

Do not allow untrusted users to create or edit Categories, Resource Categories, and Note Types with custom templates, as they could inject malicious scripts.

Only an admin can author the templates of Categories and Resource Categories, and only an editor or admin those of Note Types. That includes group import: a lower role's import creates these carriers without their templates, schema or rules.

:::

Template Locations​

Each Category (for Groups), Resource Category (for Resources), and Note Type (for Notes) defines a set of HTML template slots plus a raw CSS slot. Most slots exist on all three carriers; four exist on one carrier only, because the surface they render on exists for one carrier only.

Detail page

SlotDisplay Location
CustomHeaderTop of the entity detail page, above the description
CustomSidebarSidebar of the entity detail page
CustomPreviewResource Categories only. Sidebar, above the built-in preview image (see CustomPreview)
CustomOwnEntitiesCategories only. Replaces the body of the group detail page's Own Entities section (see CustomOwnEntities)
CustomDetailFooterBottom of the entity detail page, below every built-in section

Cards and previews

SlotDisplay Location
CustomSummaryEntity cards in list views, below the title
CustomAvatarAvatar/icon when linking to the entity
CustomHoverCardThe hover card for a link to the entity. Falls back to CustomSummary when empty (see CustomHoverCard)
CustomPanelSummaryEntity cards inside another entity's detail page panels, in place of CustomSummary. Falls back to CustomSummary when empty (see CustomPanelSummary)
CustomLightboxResource Categories only. The lightbox details panel. Falls back to CustomSidebar when empty (see CustomLightbox)
CustomCellResource Categories only. One extra cell per row in the resources details table (see CustomCell)

List pages, query results, styling

SlotDisplay Location
CustomListHeaderAbove the results on a list page, only when it is filtered to exactly this one category/type (see List page slots)
CustomListFooterBelow the results on the same pages, above the pager
CustomMRQLResultResult cards in [mrql] queries (see Custom MRQL Result)
CustomEntityPickerResultContent inside an entity picker result; selection controls remain host-owned
CustomCSSRaw CSS injected as a page-level <style> block (see CustomCSS)

Every slot above holds HTML markup except CustomCSS, which holds raw CSS and exists so the others can be styled globally without inlining <style> tags in each.

Leaving a slot empty keeps the built-in appearance. Four slots additionally fall back rather than rendering nothing: CustomHoverCard and CustomPanelSummary fall back to CustomSummary, CustomLightbox falls back to CustomSidebar, and CustomOwnEntities falls back to the built-in card grids. Setting one of those is only worthwhile when that surface should differ from the slot it borrows from.

"Empty" means unset for the hover card, the panel summary and the Own Entities body, which are chosen server-side from the stored template. It means renders nothing for the lightbox, whose content arrives pre-rendered in the JSON detail response, where an unset slot and a slot whose shortcodes produced no output are the same empty string. The two only diverge for a slot that is set to something which renders nothing -- [conditional] with no matching branch, an [mrql] with no results, [meta … inline="true" hide-empty="true"] on an absent value. In that case the lightbox shows CustomSidebar, and the hover card and the panel card show nothing.

For the same reason, the Own Entities section auto-opens whenever CustomOwnEntities is set, not when it renders something: a slot that resolves to nothing still opens the section (and still suppresses the Related Entities auto-open that would otherwise take its place).

How Custom Templates Are Rendered​

Custom template content is processed in two ways:

  • Shortcodes ([meta], [property], [mrql], [conditional], [link], [each], [partial], [using], and plugin shortcodes) are expanded server-side.
  • Alpine.js directives (x-text, x-if, :class, @click, etc.) work in the slots the outer page template wraps in an x-data scope, which is every detail-page and card slot: CustomHeader, CustomSidebar, CustomPreview, CustomOwnEntities, CustomDetailFooter, CustomSummary, CustomPanelSummary, CustomAvatar, CustomHoverCard and CustomLightbox. The full entity is available there as entity. Alpine directives do not work in CustomMRQLResult, CustomEntityPickerResult, CustomCell, CustomListHeader or CustomListFooter. The first three the shortcode engine renders server-side into a table cell or card; the list slots have no x-data wrapper and bind the carrier rather than a member entity, so there is no entity object to read. Use shortcodes instead: [meta], [property] and [conditional] in the first three, [property] and [conditional] in the list slots, where [meta] renders its empty state.

:::caution Pongo2 expressions do not work

Custom template content is not evaluated as a Pongo2 template. Expressions like {{ group.Name }} or {{ group|json }} will appear as literal text in the rendered HTML. Use Alpine.js directives or shortcodes instead.

:::

Values inside HTML attributes​

[meta path="…"] expands to a <meta-shortcode> element, so it cannot be used inside an HTML attribute. Add inline="true" there and it renders the bare value instead, HTML-escaped so a quote in the data cannot break out of a quoted attribute:

<a href="/archive/[meta path='slug' inline='true']"
title="[meta path='blurb' inline='true']">Open</a>

Use single quotes for the inner shortcode attributes so the outer HTML attribute stays intact. [property] and [item] escape the same way.

What inline="true" emits is the stored value, not the element's rendering of it. The MetaSchema's display rules belong to the element, so a labeled enum gives its stored value and not its label, a boolean gives true / false and not Yes / No, and an x-display renderer does not run. That is deliberate: the URL above has to carry the stored value. See Inline output is the stored value.

:::warning Escaping is not general attribute safety

It keeps the value inside a quoted attribute. It does not make a javascript: value safe as a whole href, survive an on* handler, contain a value in an unquoted attribute, or prevent CSS injection in style. The editor warns on those four shapes. Meta is written by anyone who can edit the entity, including the plain user role, while the template is written by an admin or editor -- so a careless interpolation crosses a privilege boundary. See Inline values inside HTML attributes.

:::

Alpine is the other route, for anything that should react in the browser: every entity-bound slot is wrapped in x-data="{ entity: … }", so :class, :href and :title can read entity.Meta.* directly.

On list cards, the full entity is embedded only when the card's rendered markup names entity as a word of its own (such as entity.Meta, ...entity or $data.entity, but not entityType or a data-entity attribute name), whether that comes from the template itself, a partial, a plugin shortcode or a raw value. Plugin code that reads the entity from a script the markup does not show must name it in the markup it emits, for example with a data-uses-entity attribute. Any other card carries a smaller copy: its scalar fields, tag and owner IDs and names, and the category's ID and name, with Meta and ownMeta as empty objects and no series. Large metadata on every card made list pages many megabytes long. A [lazy] or [reload] body rendered later still sees the full entity, because its response is merged into the card's scope.

Accessing Entity Data​

The entity is already available as entity in the Alpine.js scope. You do not need to add an x-data wrapper -- the outer template provides it.

<!-- Your template content -- no x-data wrapper needed -->
<h2 x-text="entity.Name"></h2>
<p x-text="entity.Description"></p>

For Groups, the entity includes:

  • ID, Name, Description, URL
  • CategoryId, OwnerId
  • Meta (JSON metadata object)
  • CreatedAt, UpdatedAt

For Notes, the entity includes:

  • ID, Name, Description
  • NoteTypeId, OwnerId
  • Meta (JSON metadata object)
  • StartDate, EndDate
  • CreatedAt, UpdatedAt

For Resources, the entity includes:

  • ID, Name, OriginalName, Description
  • ResourceCategoryId, OwnerId
  • Meta (JSON metadata object)
  • Hash, ContentType, FileSize, Width, Height
  • CreatedAt, UpdatedAt

Basic Examples​

Display Metadata Fields​

If groups in a "Person" category have metadata like {"birthDate": "1990-01-15", "occupation": "Engineer"}:

<dl class="grid grid-cols-2 gap-2">
<dt class="font-medium">Birth Date</dt>
<dd x-text="entity.Meta?.birthDate || 'Unknown'"></dd>

<dt class="font-medium">Occupation</dt>
<dd x-text="entity.Meta?.occupation || 'Unknown'"></dd>
</dl>

Conditional Display​

Show different content based on metadata:

<template x-if="entity.Meta?.status === 'active'">
<span class="px-2 py-1 bg-green-100 text-green-800 rounded">Active</span>
</template>
<template x-if="entity.Meta?.status === 'archived'">
<span class="px-2 py-1 bg-gray-100 text-gray-600 rounded">Archived</span>
</template>

Create links using entity data:

<template x-if="entity.Meta?.website">
<a :href="entity.Meta.website"
class="text-blue-600 hover:underline"
target="_blank">
Visit Website
</a>
</template>

<template x-if="entity.Meta?.relatedGroupId">
<a :href="'/group?id=' + entity.Meta.relatedGroupId"
class="text-blue-600 hover:underline">
View Related Group
</a>
</template>

Advanced Examples​

Iterating Over Metadata Arrays​

Use x-for to render lists, tables, or grids from array metadata. This pattern works for image galleries, badge lists, data tables, and any repeating content.

<template x-if="entity.Meta?.records && entity.Meta.records.length > 0">
<table class="w-full text-sm">
<thead>
<tr class="border-b">
<th class="text-left py-2">Date</th>
<th class="text-left py-2">Event</th>
<th class="text-right py-2">Value</th>
</tr>
</thead>
<tbody>
<template x-for="record in entity.Meta.records" :key="record.date">
<tr class="border-b">
<td class="py-2" x-text="record.date"></td>
<td class="py-2" x-text="record.event"></td>
<td class="py-2 text-right" x-text="record.value"></td>
</tr>
</template>
</tbody>
</table>
</template>

Derived totals​

A number computed from other fields stays correct when someone edits one of them, which a stored copy does not. [calc] does the arithmetic on the server from the entity's Meta, its numeric fields and [each] elements, without a query:

<table class="w-full text-sm">
<caption class="text-left font-semibold">Invoice lines</caption>
<tr><th scope="col" class="text-left">Item</th><th scope="col" class="text-right">Total</th></tr>
[each path="lines"]
<tr><td>[item path="name"]</td><td class="text-right">[calc expr="item.qty * item.price" decimals="2"]</td></tr>
[/each]
</table>
<p>Total due: [calc expr="meta.qty * meta.unit_price * (1 - coalesce(meta.discount, 0))" decimals="2" default="not set"]</p>

Dynamic Styling from Metadata​

Combine :class bindings with metadata values for status badges, progress bars, or conditional formatting.

<template x-if="entity.Meta?.progress !== undefined">
<div class="mt-4">
<div class="flex justify-between text-sm mb-1">
<span>Progress</span>
<span x-text="entity.Meta.progress + '%'"></span>
</div>
<div class="w-full bg-gray-200 rounded-full h-2">
<div class="bg-blue-600 h-2 rounded-full"
:style="'width: ' + entity.Meta.progress + '%'"></div>
</div>
</div>
</template>

CustomSummary Example​

The CustomSummary template appears in list views. Keep it compact:

<div class="text-sm text-gray-600">
<template x-if="entity.Meta?.status">
<span class="inline-block px-2 py-0.5 text-xs rounded"
:class="{
'bg-green-100 text-green-800': entity.Meta.status === 'active',
'bg-yellow-100 text-yellow-800': entity.Meta.status === 'pending',
'bg-gray-100 text-gray-600': entity.Meta.status === 'archived'
}"
x-text="entity.Meta.status"></span>
</template>
<template x-if="entity.Meta?.priority">
<span class="ml-2" x-text="'Priority: ' + entity.Meta.priority"></span>
</template>
</div>

To show what a note says rather than only its name, use [excerpt]. It strips the Markdown, HTML, mentions and shortcodes from the Description and cuts it to a few words, so a long note cannot stretch its card:

<p class="text-sm text-gray-600">[excerpt words="25" more="Read more"]</p>

On a group category, [relations] shows each card's typed relations, here only one type. Each card costs one unit of the page query budget. When the detail page shows relations through the template too, hide the built-in Relations panels under Section Visibility:

[relations type="Depends on" limit="5"]

CustomAvatar Example​

The CustomAvatar template controls how the entity appears when linked. Its placement differs by carrier, for a structural reason:

  • Group cards (via Category) and Note cards (via Note Type): CustomAvatar replaces the default initials avatar. When it is empty, the initials avatar shows instead.
  • Resource cards (via Resource Category): resource cards are thumbnail-led and have no initials avatar to replace, so CustomAvatar is shown next to the category name under the thumbnail. The Preview Image visibility control can hide the thumbnail; Category Link can hide the category name. Neither hides CustomAvatar.

This is intentional, not an inconsistency; avatar-replacement on resource cards would be a feature change, not a fix.

<template x-if="entity.Meta?.avatarUrl">
<img :src="entity.Meta.avatarUrl"
class="w-8 h-8 rounded-full object-cover">
</template>
<template x-if="!entity.Meta?.avatarUrl">
<div class="w-8 h-8 rounded-full bg-gray-300 flex items-center justify-center">
<span class="text-xs font-medium text-gray-600"
x-text="entity.Name?.charAt(0) || '?'"></span>
</div>
</template>

CustomDetailFooter​

CustomDetailFooter renders at the very bottom of the entity detail page, below every built-in section and below the CustomOwnEntities/Related Entities/Relations panels. It is the counterpart of CustomHeader: same entity binding, same Alpine scope, opposite end of the page.

It occupies roughly the same place as the group_detail_after / resource_detail_after / note_detail_after plugin slots, and the difference is who controls it. A plugin slot is global -- it renders on every entity of that kind, for whatever plugin is installed. CustomDetailFooter is per category, so one category can carry a citation block or a set of cross-links that another does not.

<footer class="entity-footer">
<p>Catalogued [property path="CreatedAt" format="date"] &middot; last touched [property path="UpdatedAt" format="date"]</p>
[conditional path="source.url" not-empty="true"]
<p>Source: <a href="[meta path='source.url' inline='true']">[meta path="source.title" default="original"]</a></p>
[/conditional]
</footer>

For items read one after another (a book's pages, a run of meeting notes), put [adjacent] in CustomHeader. It links the previous and next sibling (same owner and category, or with series="true" the same Series) in creation order:

[adjacent label="Meetings"]

CustomHoverCard​

Hovering a link to a group, resource or note shows a small preview card. By default that card shows the entity's CustomAvatar and CustomSummary -- the same markup as its list card. CustomHoverCard replaces the summary half of it.

When empty, the hover card falls back to CustomSummary, so a category that never sets this slot keeps exactly the hover card it had. Set it when the hover card should differ: the card in a list has the width of a grid cell, while the hover card is narrow and transient, so a three-column summary that reads well in a list is usually too much on hover.

<span class="hover-line">[meta path="status" default="—"] &middot; [meta path="owner.name" hide-empty="true"]</span>

The hover card is delivered as an HTML fragment and initialised with Alpine.initTree, so entity-scoped Alpine directives work here as they do on the detail page.

CustomPanelSummary​

A card shown inside another entity's detail page renders CustomPanelSummary in place of CustomSummary. The rest of the card (title, avatar, badges, description, tags and plugin actions) is unchanged. These are the panels that count:

  • on a group: Own Entities (Notes, Sub-Groups, Resources), Related Entities (Related Groups, Related Resources, Related Notes), and the Relations and Reverse Relations panels,
  • on a note: Groups and Resources,
  • on a resource: Notes, Groups, Series and Similar Resources,
  • on a series: Resources,
  • on a tag, category, note type or resource category page: its Groups, Notes or Resources panel.

When empty, those cards fall back to CustomSummary, so a carrier that never sets this slot keeps the cards it had. No other card surface uses CustomPanelSummary. List pages, the dashboard, the /relation page and the owner card in a detail page's sidebar render CustomSummary. MRQL result cards and the hover card keep their own selection: CustomMRQLResult and CustomHoverCard when set, otherwise what they rendered before.

The slot renders against the card's own entity, not the page it appears on: on a parent group's page, [property path="Name"] in a child group's panel summary is the child's name. A common use is a shorter card inside a parent than in the full list:

<span class="panel-line">[meta path="status" default="—"] &middot; due [meta path="due" default="—"]</span>

CustomOwnEntities​

Categories only. The group detail page has an Own Entities section listing the notes, sub-groups and resources the group owns, as three card grids. CustomOwnEntities replaces the body of that section.

The usual reason to set it is to present children as data rather than as cards -- an [mrql] table sorted by a metadata field, say, instead of three grids ordered by creation date.

[mrql query='type = resource AND owner = entity' format="table" limit="50"]

Two rules to keep in mind:

  • The section's visibility is still governed by Section Config. Setting this slot while Own Entities is switched off renders nothing -- the slot replaces the section body, it does not re-enable the section.
  • The section auto-opens when it has content, and a CustomOwnEntities body counts as content. A group that owns nothing but whose category sets this slot still opens the section, and Related Entities no longer auto-opens in its place.

CustomPreview​

Resource Categories only. CustomPreview renders in the resource detail sidebar, directly above the built-in preview image. It exists for file types the built-in preview cannot show: a PDF or 3D model viewer, an audio waveform, an embed for a resource whose real content lives elsewhere.

It adds to the preview image rather than replacing it. The image has its own Section Config toggle (PreviewImage); switch that off if the category's own preview should stand alone.

[conditional field="ContentType" eq="application/pdf"]
<object data="/v1/resource/view?id=[property path=&quot;ID&quot;]" type="application/pdf" width="100%" height="420"></object>
[/conditional]

CustomLightbox​

Resource Categories only. Clicking a resource thumbnail opens the lightbox, whose details panel shows the resource's metadata. That panel renders CustomSidebar by default; CustomLightbox replaces it.

When empty, the panel falls back to CustomSidebar, so a category that never sets this slot keeps the panel it had. Set it because the two surfaces do not look alike: the detail page sidebar is a light column on a white page, while the lightbox panel is a narrow dark column over the image. Markup tuned for one usually reads badly in the other.

<dl class="lightbox-meta">
<dt>Shot</dt><dd>[meta path="exif.taken" default="unknown"]</dd>
<dt>Camera</dt><dd>[meta path="exif.camera" default="—"]</dd>
</dl>

Both slots are expanded server-side before the JSON response is serialized, so shortcodes resolve normally even though the lightbox is rendered in the browser.

For photo libraries, [similar] in CustomLightbox or CustomSidebar puts the image's stored lookalikes, each with a Duplicate or Similar badge and a Compare link, next to the image being reviewed.

CustomCell​

Resource Categories only. The resources list has a table view (/resources/details) with fixed columns: ID, Name, Preview, Size, Created, Updated, Original Name, Original Location. CustomCell adds one more column, headed Custom, rendered once per row.

The column appears only when the list is filtered to exactly this one category -- the same rule the list header and footer use. A mixed list has no single template to run, and a column present for some rows and absent for others is not a table.

Two constraints:

  • Output the cell body, not a <td>. The table supplies the cell.
  • Keep it short. The table already scrolls horizontally at typical widths; a long value pushes the built-in columns out of view.
[meta path="status" default="—"]

Shortcodes are processed against the row's resource, so [meta] and [property] read that resource. Alpine directives do not apply.

List page slots​

CustomListHeader and CustomListFooter render a banner above and below the results of a list page, but only when the list is filtered to exactly one category/type -- a group list at /groups?categories=42, a resource list at /resources?resourceCategoryId=7, or a note list at /notes?noteTypeId=3. Unfiltered lists, and lists filtered to more than one category, show neither. They are the natural home for a category "dashboard": a title and a few [mrql] counts above, totals or a legend below.

Unlike the other slots, both are processed with the category/type itself as the entity, not a member group/resource/note. This has four consequences:

  • [property path="Name"] yields the category's own name (and path="Description" its description). Other [property] paths that expect a member entity's fields will be empty.
  • [meta] renders its empty state -- a category carries no Meta, so a [meta path="..." default="—"] shows the default.
  • [mrql] resolves against global scope (not a group subtree), so dashboard queries count across the whole instance. Add an explicit scope="..." attribute if you want to narrow it.
  • [reload] falls back to reloading the page -- the deferred-render endpoint cannot load a category/type by id, so the header has no region of its own to re-render. For the same reason [lazy], [details] and lazy [tabs] tabs render inline here instead of deferring, and [autorefresh] renders once and never refreshes.
<div class="cat-dashboard">
<h2>[property path="Name"]</h2>
<p>[property path="Description"]</p>
<p><strong>[mrql query="type = group" value="count"]</strong> groups in this instance</p>
</div>

Style them from the same CustomCSS field: the markup ships inside a custom-list-header or custom-list-footer wrapper. Their previews on the edit form render against the category itself, so they work only once the category has been saved.

The footer sits below the results and above the pager, so it reads as the end of the content rather than as page chrome.

CustomCSS​

Categories, Resource Categories, and Note Types each have a CustomCSS field. Unlike every other Custom* slot, it holds raw CSS, not HTML. The content is injected verbatim into a page-level <style> block, so you can style all the other slots from one place instead of inlining <style> in each template.

/* Style the CustomHeader and CustomSummary markup for this category */
.person-header h2 {
font-variant: small-caps;
}
.person-card > .badge {
background: #1e3a8a;
color: white;
}

Where It Is Injected​

A category's CustomCSS is emitted on every page that renders one of its slots:

  • the entity detail page,
  • any card of the category, wherever it appears: list pages, the dashboard, the category, tag, note and resource pages, and a group's owned, related and relation panels,
  • [mrql] result cards,
  • the hover card,
  • the lightbox details panel, and
  • CustomListHeader and CustomListFooter, including on timeline views and on a filtered list with no results.

Each distinct category emits its block at most once per page render, so a page with many cards gets one <style> block per category rather than one per card. In the browser each block is moved into the page head as soon as it arrives, so it stays when the content it came with is replaced: a card list refreshed in the background, a [reload] region, an [autorefresh] body, a note text block or the hover card. The lightbox details panel always carries its own copy of its category's CSS.

Raw Injection​

CustomCSS is injected unescaped, on purpose. Mahresources is a trusted, private-network tool, and CustomCSS is an intentional extension point, so real CSS -- selectors containing >, content() with quotes, and the like -- survives verbatim. As with the other custom slots, only allow trusted users to edit it (see the security notice at the top of this page).

Shortcodes ([meta], [property], [mrql]) inside CustomCSS are processed server-side using a representative entity of the category, so values resolve before the block is written. Alpine.js directives do not apply -- a <style> block is static.

Creating Categories with Templates​

  1. Navigate to Categories
  2. Click Create
  3. Fill in the Name and Description
  4. Add your templates in the appropriate fields:
    • Custom Header - top of the group detail page
    • Custom Sidebar - the group detail page sidebar
    • Custom Detail Footer - bottom of the detail page, below every built-in section
    • Custom Summary - group cards in list views
    • Custom Avatar - replaces the initials avatar on group cards
    • Custom Hover Card - the hover card for a group link; falls back to Custom Summary
    • Custom Panel Summary - group cards inside another entity's detail page panels; falls back to Custom Summary
    • Custom Own Entities - replaces the body of the Own Entities section
    • Custom List Header / Custom List Footer - above and below a list filtered to exactly this category
    • Custom MRQL Result - result cards in [mrql] queries
    • Custom CSS - one CSS block styling all of the above
  5. Click Submit

Every field has a Generate button (natural-language drafting) and a live Preview pane; see Editor authoring tools.

Creating Resource Categories with Templates​

  1. Navigate to Resource Categories
  2. Click Create
  3. Fill in the Name and Description
  4. Add your templates in the appropriate fields:
    • Custom Header - top of the resource detail page
    • Custom Sidebar - the resource detail page sidebar, and the lightbox panel unless Custom Lightbox is set
    • Custom Preview - sidebar, above the built-in preview image
    • Custom Detail Footer - bottom of the detail page, below every built-in section
    • Custom Summary - resource cards in list views
    • Custom Avatar - shown next to the category name on resource cards
    • Custom Hover Card - the hover card for a resource link; falls back to Custom Summary
    • Custom Panel Summary - resource cards inside another entity's detail page panels; falls back to Custom Summary
    • Custom Lightbox - the lightbox details panel; falls back to Custom Sidebar
    • Custom Table Cell - one extra column in the resources details table
    • Custom List Header / Custom List Footer - above and below a list filtered to exactly this category
    • Custom MRQL Result - result cards in [mrql] queries
    • Custom CSS - one CSS block styling all of the above
  5. Optionally define a MetaSchema (JSON Schema for metadata validation)
  6. Click Submit

Creating Note Types with Templates​

  1. Navigate to Note Types
  2. Click Create
  3. Fill in the Name and Description
  4. Add your templates in the appropriate fields:
    • Custom Header - top of the note detail page
    • Custom Sidebar - the note detail page sidebar (both default and wide layouts)
    • Custom Detail Footer - bottom of the detail page, below every built-in section
    • Custom Summary - note cards in list views
    • Custom Avatar - replaces the initials avatar on note cards
    • Custom Hover Card - the hover card for a note link; falls back to Custom Summary
    • Custom Panel Summary - note cards inside another entity's detail page panels; falls back to Custom Summary
    • Custom List Header / Custom List Footer - above and below a list filtered to exactly this note type
    • Custom MRQL Result - result cards in [mrql] queries
    • Custom CSS - one CSS block styling all of the above
    • Apply templates to public share pages - opts Custom Header and Custom CSS into the public /s/<token> page. Off by default, and on that surface the templates run restricted: [mrql] and plugin shortcodes do not run, and [meta] is read-only. See Note Sharing
  5. Click Submit

Note Types carry the shared slots only. The four carrier-specific slots (Custom Preview, Custom Lightbox, Custom Table Cell, Custom Own Entities) have no surface on a note.

Shortcodes​

Shortcodes let you embed dynamic content in custom templates without writing Alpine.js code. The built-in shortcodes are:

  • [meta] -- Schema-aware metadata display with optional inline editing
  • [pills] -- Pill selector using enum or manual choices, e.g. [pills path="priority" editable="true"]
  • [property] -- Entity field values (Name, CreatedAt, etc.)
  • [mrql] -- Inline MRQL query results in various formats
  • [conditional] -- Show or hide content based on a field, property, or MRQL result
  • [link] -- The detail-page URL of the current entity
  • [each] / [item] -- Iterate over an array in the entity's metadata
  • [partial] -- Include a reusable shared snippet by name
  • [lazy] / [details] -- Defer rendering until the block scrolls into view or is opened
  • [tabs] -- Alternative sections as an accessible tab set; a lazy="true" tab renders only when first opened
  • [reload] -- Button that re-renders the innermost [lazy]/[details]/[autorefresh] block, or else the whole custom-content slot, in place
  • [autorefresh] -- Re-render a block in place after an inline editor saves, so content the server expanded follows the edit
  • [action] -- A button that runs a plugin action on this entity as the person who clicks it, then refreshes the [autorefresh] blocks around it
  • [using] -- Render a block with another group, resource or note (the owner, or an ID from metadata) as the entity
  • [calendar] -- A month grid of the entities an MRQL filter matches, by a created, updated or Meta date, with titles, day links and Prev/Next navigation
  • [pivot] -- A cross-tab of two fields over the entities an MRQL filter matches, with a count or sum in each cell, row, column and grand totals, and count links to the MRQL page
  • [comment] -- Comment out a section. The server removes it before rendering, so its shortcodes never run and it is never rendered. An HTML comment still runs its shortcodes and is sent to the browser.

Plugins can also register custom shortcodes via mah.shortcode().

See the Shortcodes page for full syntax, attributes, and examples.

Editable meta inside styled wrappers​

Editable [meta] fields can be wrapped in custom HTML for card-like layouts. The app treats the emitted shortcode element as component-owned during background morph refreshes: wrapper HTML and shortcode attributes update from the server, while the shortcode's generated controls re-render themselves.

<div style="display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start;">
<div style="flex: 1 1 200px;">
<label style="font-weight: 600; display: block; margin-bottom: 0.25rem;">URL</label>
<div style="border: 1px solid #d1d5db; border-radius: 0.375rem; padding: 0.5rem; background: #f9fafb;">
[meta path="url" editable="true"]
</div>
</div>
<div style="flex: 1 1 200px;">
<label style="font-weight: 600; display: block; margin-bottom: 0.25rem;">Active Status</label>
<div style="border: 1px solid #d1d5db; border-radius: 0.375rem; padding: 0.5rem; background: #f9fafb;">
[meta path="active" editable="true"]
</div>
</div>
</div>

Do not add x-ignore to these shortcode wrappers; it can prevent useful server-side updates from reaching the editable field.

Section Configuration​

Categories, Resource Categories, and Note Types can define a sectionConfig JSON field that controls which built-in sections appear on entity detail pages and list cards.

How It Works​

When a category has a sectionConfig set, its entities show or hide the corresponding built-in sections. Any section not mentioned in the config defaults to visible. An empty config (or no config) shows all sections.

The same controls apply to matching sections on list cards:

CardControls
GroupDescription, Tags, Timestamps
ResourceDescription, Tags (including Edit Tags), Owner, File Size, Category Link, Preview Image
NoteContent (description preview and inline editor), Tags

Each card uses its own category or note type, including mixed-category lists and cards inside another entity's detail page. These settings also apply to the group text list and resource simple list, which use the same cards. Controls for sections that have no counterpart on cards still apply only to detail pages.

CustomSummary, CustomPanelSummary and CustomAvatar remain visible when built-in card sections are hidden. Selection controls, entity titles, relation descriptions and plugin actions remain available. Table rows, timeline entries, hover cards, the lightbox, custom MRQL templates and public shares retain their separate rendering behavior.

To replace the built-in group or resource description with your own card layout, uncheck Description in Section Visibility and put this in Custom Summary:

<p class="my-card-description">[property path="Description"]</p>

The description remains available to the template, and only your custom rendering appears on the card. Use Custom Header to render your replacement on the detail page too. For notes, uncheck Content instead; this also hides the default description and blocks on note detail pages.

Setting via the UI​

  1. Navigate to Categories, Resource Categories, or Note Types
  2. Create or edit an entry
  3. Use the Section Visibility form to toggle sections on/off
  4. Save

JSON Format​

The sectionConfig is a JSON object. Each key corresponds to a built-in section, with the matching card behavior listed above. Boolean keys default to true (visible). Object keys support a state field with collapsible behavior on detail pages.

Collapsible states:

StateBehavior
"default"Follows the application default
"open"Initially expanded
"collapsed"Initially collapsed
"off"Hidden entirely

Group Sections (via Category)​

{
"tags": true,
"timestamps": true,
"metaJson": true,
"metaSchemaDisplay": true,
"description": true,
"merge": true,
"clone": true,
"treeLink": true,
"owner": true,
"breadcrumb": true,
"ownEntities": {
"state": "default",
"ownNotes": true,
"ownGroups": true,
"ownResources": true
},
"relatedEntities": {
"state": "default",
"relatedNotes": true,
"relatedGroups": true,
"relatedResources": true
},
"relations": {
"state": "default",
"forwardRelations": true,
"reverseRelations": true
}
}

Resource Sections (via Resource Category)​

{
"metadataGrid": true,
"timestamps": true,
"notes": true,
"groups": true,
"tags": true,
"versions": true,
"similarResources": true,
"series": true,
"metaJson": true,
"metaSchemaDisplay": true,
"description": true,
"previewImage": true,
"imageOperations": true,
"categoryLink": true,
"fileSize": true,
"owner": true,
"breadcrumb": true,
"technicalDetails": {
"state": "default"
}
}

Note Sections (via Note Type)​

{
"content": true,
"groups": true,
"resources": true,
"timestamps": true,
"tags": true,
"metaJson": true,
"metaSchemaDisplay": true,
"owner": true,
"noteTypeLink": true,
"share": true
}

To hide a section, set its key to false. For example, to hide timestamps and the raw JSON sidebar on notes:

{
"timestamps": false,
"metaJson": false
}

Custom MRQL Result Templates​

Categories, Resource Categories, and Note Types can define a customMRQLResult field containing a shortcode template that controls how entities of that type render in [mrql] shortcode results. The template is processed by the shortcode engine (not Pongo2), so [meta], [property], and nested [mrql] shortcodes work, but {{ }} expressions do not.

How It Works​

  1. Set the customMRQLResult field on a Category, Resource Category, or Note Type
  2. When an [mrql] shortcode query returns entities of that type, the custom template is used instead of the default card layout -- unless the [mrql] shortcode itself provides a block template, which takes precedence over all category-level templates
  3. The template has access to the entity context, so shortcodes like [meta] and [property] work inside it

Setting via the UI​

  1. Navigate to Categories, Resource Categories, or Note Types
  2. Create or edit an entry
  3. Enter a template in the Custom MRQL Result textarea
  4. Save

Example​

A Category with this customMRQLResult:

<div class="recipe-result">
<strong>[property path="Name"]</strong>
<span class="recipe-result__status">[meta path="status"]</span>
</div>

When an [mrql] query returns groups in this category, each result renders using this template instead of the default link card.

Format and Template Precedence​

Template selection follows this priority:

  1. Block template -- if the [mrql] shortcode uses block syntax with non-empty content, that block body is the per-item template. customMRQLResult and format are both ignored.
  2. Explicit format -- format="table", format="list", or format="compact" override custom template rendering.
  3. customMRQLResult -- when format is empty (auto) or "custom", entities with a customMRQLResult use it; entities without one fall back to the default card layout.
  4. Default card layout -- used when none of the above apply.

Styling Tips​

Use Template-Owned CSS​

App-owned classes and Tailwind utilities are implementation details and may change. Give custom markup distinctive classes and define their presentation in the category's Custom CSS field:

<article class="recipe-card">
<h3 class="recipe-card__title">Title</h3>
<p class="recipe-card__description">Description text</p>
</article>
.recipe-card {
padding: 1rem;
border: 1px solid #d6d3d1;
border-radius: 0.5rem;
}

.recipe-card__title {
font-size: 1.125rem;
font-weight: 600;
}

.recipe-card__description {
margin-top: 0.5rem;
color: #57534e;
}

Responsive Design​

Use ordinary media queries in Custom CSS:

.recipe-grid {
display: grid;
grid-template-columns: 1fr;
gap: 1rem;
}

@media (min-width: 48rem) {
.recipe-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 64rem) {
.recipe-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

Nested Alpine.js Scopes​

If you need additional reactive state (toggles, counters, etc.), create a nested x-data scope. The parent entity variable remains accessible:

<div x-data="{ showDetails: false }">
<button @click="showDetails = !showDetails" class="text-sm text-blue-600">
Toggle Details
</button>
<div x-show="showDetails" class="mt-2">
<p x-text="entity.Meta?.notes || 'No notes'"></p>
</div>
</div>

Debugging Templates​

If a template does not render correctly:

  1. Check the browser console for JavaScript errors
  2. Verify the entity JSON is valid (view page source)
  3. Test with a minimal template first, then add complexity
  4. Use x-text to debug values: <span x-text="JSON.stringify(entity.Meta)"></span>

MetaSchema for Validation​

Categories, Resource Categories, and Note Types support a MetaSchema field -- a JSON Schema that validates metadata. This is separate from templates but works well together:

  1. Define a MetaSchema to ensure required fields exist
  2. Create templates that rely on those fields
  3. Users get validation errors if metadata is incomplete

A MetaSchema must compile to be saved. Its pattern and patternProperties regular expressions, and those the JSON Schema metaschema checks, are compiled under the same allowance as [conditional matches], counted for the whole schema; a schema past it is refused with an error naming the allowance. For the same reason a schema is refused before compiling when a number has an exponent outside ±400 or more than 100 significant digits, when its numbers hold more than 10,000 digits in all, when it nests more than 64 levels deep, or when it holds more than 500,000 JSON tokens (property names and the brackets that open and close objects and arrays count as tokens).

Example MetaSchema:

{
"type": "object",
"required": ["status", "priority"],
"properties": {
"status": {
"type": "string",
"enum": ["active", "pending", "archived"]
},
"priority": {
"type": "integer",
"minimum": 1,
"maximum": 5
}
}
}

Revision history​

Every save that changes a template slot, its CSS, the Meta JSON Schema or the section configuration is recorded as a Template Revision. You can compare any two revisions, load an old slot back into the editor, or restore it from the API or CLI. See Template Revisions.

Editor authoring tools​

The Category, Resource Category, and Note Type edit forms provide a feedback loop for authoring the Custom* template slots (including CustomCSS, which supports shortcodes). These tools apply only to the template slots -- the Meta JSON Schema editor is unaffected.

Each template slot and its CSS companion sit in one collapsible section, titled after the slot and closed when the form loads. Click the title to open the section. A section opens by itself when a preset, a copy, an imported bundle or a loaded revision changes a field in it, so a change you did not type is never hidden. The Custom CSS editor sits below the sections and is always shown.

Live preview​

Every template slot's section ends with its own preview, which renders that slot against a real entity without saving:

  • Pick the entity to render against once, in Preview against at the top of the template fields. Every slot preview uses it. When editing an existing category or note type, the search and the default pick are restricted to entities of that category (the choice is remembered per category in the browser). On the create form, where no entity can belong to the new category yet, the pick falls back to all entities and defaults to the most recent one. When the category has no members yet, the previews borrow an entity from elsewhere and say so.
  • The List Header and List Footer previews render against the category itself, so they work only once the category has been saved.
  • Each preview renders its slot with the full CSS cascade from the form: CustomCSS first, then every slot's CSS companion (the Entity Picker Result preview uses only CustomCSS and its own companion, as the picker does). CustomCSS has no preview of its own, since the shared stylesheet adds no markup; editing it re-renders the slot previews.
  • A preview renders the first time it scrolls into view, so a preview in a closed section waits until the section is opened. Editing its slot, or any CSS field, re-renders it after a short pause if it is in view; a preview out of view renders when it is next seen. Refresh re-renders one preview and Refresh all previews re-renders every visible one.
  • The result renders in a sandboxed <iframe> that includes the app's CSS and JS bundle, so [meta] web components and Alpine widgets hydrate. The sandbox is origin-isolated, so widgets that need API calls are non-functional in preview; the note under Preview against states this.
  • The rendered slot is wrapped in the same x-data="{ entity: ... }" Alpine scope the display pages provide, so expressions like x-text="entity.Name" behave as they will on the real page.
  • A failed shortcode shows only its name in the frame, so each preview lists its render errors in full below the frame, along with lint issues.

On the edit form, each slot's preview has a History button, and the Custom CSS editor has one too. It opens the slot's previous versions in a dialog where you can compare one with the editor, preview it and apply it. See Slot history on the edit form.

Preview executes MRQL and plugin shortcodes, so it is gated at the same permission level as saving the template: admin for Category and Resource Category, editor for Note Type. To keep it responsive on large deployments, [mrql] result limits are capped during preview.

To see what a template can read at a given point, add [inspect] there. The preview shows a collapsed panel listing the Meta paths with their types and sample values, the entity's fields, and, at the top level of an [each] body, the element's [item] paths. Each row has a snippet to copy. [inspect] renders only in the preview and renders nothing on pages, so leaving one in a saved template does no harm. See [inspect].

[each path="steps"]
[inspect]
<li>[item path="title"]</li>
[/each]

Linting​

The template editors underline problems as you type -- unclosed [conditional] blocks, closing tags on inline shortcodes, unknown attributes, missing required attributes, [mrql] without a query/saved, MRQL that rendering would reject, likely shortcode typos, and bracketed words that are not shortcodes at all, such as [draft], which render as literal text (an info note; slot dividers like [header] and [else], and index-like text such as items[0], are not noted). MRQL is checked in every query a template runs: [mrql query], [conditional mrql] with its numbered mrql2, mrql3, … sources, and [elseif] guards. Each query is checked with its shortcode's param-*, limit and buckets attributes applied as rendering applies them, so an unbound $name, an unused param-, a field the entity does not have, a regex match on SQLite or a limit above 10,000 is underlined. The check never touches the database: whether a SCOPE group or a saved query exists is only known when the template renders. Diagnostics are colored by severity (error, warning, info). Lint reads at most 1 MiB of a slot or schema; a larger one gets a single error saying it is too large to check, and is still saved and rendered as usual. A matches pattern past the regular expression allowance is underlined as an error, since it never matches. Linting never blocks saving: if a slot still has errors when you submit, a confirmation asks whether to save anyway. This preserves the trust model, which allows arbitrary HTML and must tolerate false positives.

Autocomplete and hover docs​

Inside a [ bracket the editor suggests shortcode names, then attribute names, then values for closed enums (scope, format, boolean flags). For [meta]/[conditional] path= values, suggestions are drawn from the Meta JSON Schema you are editing in the same form. Hovering a shortcode name shows a documentation card. HTML tag and CSS property completion outside of brackets is unaffected.

Generate from natural language​

Configure the template provider, model and key in the AI generation section at /admin/settings to use each editor's Generate button. DeepSeek, OpenRouter, OpenAI and Anthropic are supported, and templates can use a different provider/model from natural-language MRQL. Existing DEEPSEEK_API_KEY deployments keep using DeepSeek by default. Describe the section you want and the server drafts it for review. By default the request runs as a Generation run; the rest of this section describes the data a request sends and the single-call flow of classic mode (repair, whole-template planning and fan-out), and the starting message of a Generation run carries the same data. Depending on the target, the messages include:

  • your request, the category or type's name and description, and the current unsaved Meta JSON Schema;
  • the section visibility settings and a summary of sibling slots' class names and styles, including shared CSS;
  • a bounded summary of up to five category members' metadata and selected properties, plus up to three projected samples. The selected preview entity comes first when it belongs to the category. On a create form, only the preview entity you selected is sampled;
  • the current unsaved content of the requested slot or slots, so a follow-up request can refine it;
  • the built-in and enabled-plugin shortcode documentation, enabled plugin metadata and note-block registrations, and the MRQL language reference;
  • the partial catalogue's names, descriptions and fields read, within its size budget, plus the names of partials the current content includes;
  • for MetaSchema generation, the schema-extension reference and enabled plugin display types; and
  • the system instructions, authoring rules, slot roles and output format for each call.

Before anything is sent, Generate shows a Review what will be sent dialog listing every message the request would send to the provider, split into labelled parts: the request, the schema, the sample values and the current content are expanded, and the long constant reference text (the system prompt and the shortcode reference) is collapsed with its size. The dialog also names the provider host, the model, reasoning mode, output budget and timeout for each kind of call, and how many calls the request can make. Nothing is sent until you press Send; Cancel or Escape sends nothing. The server refuses a request whose data or provider/model/options changed after review (for example, a newer member entity became the sample) and the status then offers Review again. A running generation keeps the same configuration through planning, section calls and repair.

A draft with lint errors or an incomplete HTML/CSS pair gets one automatic repair attempt when time permits. That call appends the previous model reply and the server's validation issues to the original message; the dialog shows placeholders for those values before they exist. A repair replaces the first draft only when it improves the diagnostics and retains the content. The status identifies an applied repair. Truncated or unparseable replies are not repaired. An unsuccessful repair keeps the original diagnostic draft for a single section; a whole-template request leaves a still-invalid section out. Set DEEPSEEK_TEMPLATE_REPAIR=0 to disable repair.

A generated slot is linted before it is returned. Every draft, clean or not, is held for review below the prompt: its text is shown as plain text, never rendered, with constructs that run code once applied (<script>, event handlers, Alpine attributes, javascript: URLs, </style in CSS) highlighted as a reading aid, and any issues listed. Nothing reaches the editor or the live preview until you press Apply. If you edited a field the draft would replace while it was being generated, Apply names that field and asks before replacing it. The Meta JSON Schema editor has its own Generate button that drafts a JSON Schema from a description. The request teaches the model the schema extensions this app reads (x-display with its built-in and enabled-plugin values, the formats with their own input, labeled enums, x-color), and the draft is checked that it compiles and then linted. A schema draft is invalid when it is not valid JSON, does not compile, is cut off at the model's output limit, or exceeds 20,000 bytes. Everything else the lint reports is a warning that says what the page will draw instead: an x-display that is not a string (ignored), unknown (it suppresses shape detection, so an object value is drawn as a plain object) or not provided by an enabled plugin; a built-in renderer on a property that is not an object, or whose keys are missing, mistyped or absent from required (a value the renderer rejects is drawn by its normal type rendering, which for an object is a plain object); a property name outside letters, digits and underscores, or one MRQL cannot address as meta.<name> (it starts with a digit or is a reserved word such as and or limit); and a labeled enum that an extra key turns into a plain subschema. The renderer checks read keys and types through local $ref and allOf (keywords next to a $ref count only under $schema 2019-09 or later). They are skipped when the answer depends on context the lint does not model: anyOf or oneOf, an annotated schema that is itself a composition branch or a referenced definition, a property under a node that composes other schemas, or a schema that uses a keyword beyond type, properties, required, $ref, allOf, plain annotations and value constraints (including key-count bounds such as minProperties); for example dependentSchemas, if, not, patternProperties or a schema-valued additionalProperties skip the check.

The Reuse & Presets panel adds a Generate whole template box that designs a template from one description. Above the Generate button, a Sections to generate group lists the sections this type has (each template slot is written together with its CSS companion) and Shared CSS (CustomCSS). Tick the sections you want. With none ticked, the generator chooses which sections the description needs. Generation can take a minute or longer, depending on the selected provider and call budgets.

A whole template is written in steps. When it covers more than one section, or Shared CSS, one planning call first settles a design shared by all sections: a class prefix, a palette, a layout, which sections to fill, and, when Shared CSS is in the request, new shared CSS rules. Then one call per section writes that section's template and its CSS companion, at most five at a time, within one 55s deadline for DeepSeek or 120s for other providers. A single section without Shared CSS is one call. The Review what will be sent dialog lists the planning call and one message for every section that might be written. In those section messages the design plan appears as the placeholder {{model output: design plan}}, because the plan exists only after the planning call replies, and only the model's own output ever fills a placeholder. The dialog counts each section as up to two calls, since a section that has lint errors is repaired once. The planning call is never repaired, and a planning call that fails fails the request with no section call made.

A section that fails (a provider error, a timeout, a reply cut off at the output limit, or a pair still broken after its repair) is left out of the draft. A warning above the draft names it, and the other sections are kept. Generate it on its own afterwards. A section the generator did not choose is simply absent from the draft, so its editor keeps its content. If every section fails, nothing is returned. Shared CSS is append-only: the draft's CustomCSS is your current CustomCSS followed by the new rules, and your existing rules are never rewritten, so a section that was skipped or failed keeps the styles it depends on. Shared CSS is left out of the draft when there are no new rules, and a selection that leaves its box unticked never changes it. To rewrite it, use the CustomCSS editor's own Generate button.

The draft is listed for review, each returned slot with its text and issues, and nothing is written to the form until you press Apply. Apply asks one question before it writes anything. It names each returned field whose current content differs from the draft and is either not empty or was changed while the request ran (a field you cleared meanwhile is named too), marks the ones edited since you asked, and does not mention fields the draft does not return. A reply cut off at the model's output limit, or a slot over 20,000 bytes, is marked invalid with that issue and is never shortened.

Before and after. Both review panels compare the draft with the fields as they stood when you pressed Generate, which is the content the model was given. A summary lists each field the draft returns with what Apply does to it: New: N lines for a field that was empty, Cleared: removes N lines for one the draft empties, No change, Changed: +A / -R lines (B to C) counted line by line, or Not applied for a field Apply leaves alone (half a pair, or one Privacy mode withheld, with its companion). The whole-template summary also counts the slots that change, are unchanged, and are not applied. A changed or cleared field that had content gets a Show line changes view, with removed lines marked - and added lines +; unchanged lines more than three away from a change fold into one N unchanged lines row. When the parts that differ are too large to compare (more than a million line pairs), every old line is listed as removed and every new line as added. The panel is headed Draft ready when the draft is valid and every field in it can be applied, and the whole template had no section fail; otherwise it is headed Draft needs review.

Knowing a request has ended. When a request you sent ends with a draft, an error, or a refusal because what would be sent changed, and its result is not on screen, a notice appears in the bottom corner saying how it ended. Review (Show for a failure) scrolls to the result, or to the error message, and focuses it; Dismiss, or Escape pressed anywhere while no dialog is open, closes the notice; when focus was on the notice, it returns to where it was when the notice appeared. Otherwise it closes by itself 15 seconds after neither the pointer nor focus is on it. If the tab is in the background when the request ends, its title starts with (Draft ready), (Draft needs review) or (Generation failed) until you return to the tab. A run you cancelled shows neither. In a harness run, the run panel's end line is green when the run finished, red when it failed, and grey when cancelled.

Generation requires a model and key for the selected provider (the button returns "not configured" otherwise), is rate-limited per account when authentication is on (per connection IP otherwise), and is gated at the same permission level as saving the template: admin for Category and Resource Category, editor for Note Type. One generation request uses one rate-limit slot, including its planning, section and repair calls. At most eight template provider calls run at once across the server, including across configuration changes. Runtime provider settings control models, token budgets and timeouts; Template generation configuration describes DeepSeek thinking defaults.

Generation runs​

With the default ai_template_generation_mode of harness, one request is a Generation run: up to a set number of Turns, in which the model may ask the server for read-only Tools before it submits a draft. The Tools read entities and their related entities (owners, owned entities and links), saved templates, template revisions, partials and shortcode documentation, lint a field, check an MRQL query without running it, and render a preview of the model's own draft against a real entity. A run's lint also warns about a [meta] path whose first segment the Meta JSON Schema does not declare (a likely typo; metadata can hold undeclared keys, and the check is skipped inside [using], [mrql] and [each] and for schemas built with allOf, anyOf, oneOf or $ref), and about HTML elements left open or closed without being opened. A preview returns, beside the rendered HTML and CSS, the text a reader would see: each [meta] shows what the page shows: its value (a labeled enum's title, Yes or No for a boolean), or when empty its default or Label: —. Values with a custom display (x-display, date-time layouts, plugin renderers) show the stored value. That text is capped at 4 KiB. The model submits fields as it goes (submit), reads the lint result of each submission, and refines. The last submission of each field is kept, and the draft you review is built from them. Set ai_template_generation_mode to classic to keep the single-call flow described above; see the settings.

What you approve. A run reads live data as it goes, so the Review what will be sent dialog states the Envelope instead of every message: the Tools read everything your account can read, no more, at the time each Tool runs. The dialog also lists the Tools, the caps (Turns, deadline, token budget, calls per Turn, Tool timeouts and each Tool's result cap), the provider and model. It carries two checkboxes, both off by default, that widen what a preview may read:

  • Previews run [mrql] queries. Off, an [mrql] shortcode in a preview renders an inert placeholder. On, its queries run against your data within the preview limits (at most 5 rows per query).
  • Previews run plugin shortcodes. Off, a plugin shortcode in a preview renders a placeholder. On, it runs read-only. A plugin shortcode runs the installed plugin's code with its own resource use; the preview limits do not apply inside it.

Ticking a box refreshes the dialog, and the choice is part of what you approve: a request whose opt-ins or Envelope changed after review is refused until you review again. Opt-ins apply to one run and are ignored in classic mode.

While it runs. A progress panel under the prompt shows the current Turn against the Turn cap, the token budget used against the budget, and a list of the Tools each Turn called (the Tool name, a few identifying arguments such as the field name or entity ID, the size of the result, and whether it failed) and the fields submitted with their error and warning counts. It never shows entity content while the run is in progress.

  • Finish now makes the next Turn the last one: the model is asked to submit and no other Tool runs in it. The panel says the next Turn will be the last.
  • Cancel stops the run and discards it. Leaving the page does the same.

When the run ends, the panel names how it ended and the Transcript lists every message sent to and received from the provider, each with its Turn, size and exact text (and, for a message that has one, the provider's own payload, shown as the exact bytes the server recorded in replayText), and marks Tool results that were never sent. The transcript is shown once and not stored.

A run ends with one of these reasons: done (the model submitted with done), turn_cap, finish_now, deadline, budget, privacy_guard (see Privacy mode), length_repeated (two Turns in a row whose reply was cut off at the output limit without a complete Tool call), no_tool_call (the model replied with no Tool call a second time in the run, the first time getting a one-line reminder to call submit, or replied with none on the final Turn) or provider_error. When a run ends without done but the model had already submitted fields, you get the last submitted draft (except privacy_guard, which never returns a draft); for deadline and provider_error the draft carries a warning that the run ended early. When it submitted nothing, you get an error. The draft is linted again, held for review, and applied only when you press Apply, exactly as in classic mode.

Limits. Four runtime settings bound a run:

SettingDefaultBoundsMeaning
ai_template_generation_modeharnessharness, classicHow a request is run
ai_template_max_turns101–20Turns in one run
ai_template_run_deadline5m30s–15mWall-clock limit of one run
ai_template_run_token_budget400000100000–2000000Tokens in one run; cached prompt tokens count a quarter

A Turn calls at most 6 Tools, which run in parallel. A preview renders its HTML and its CSS each under an output budget of 256 KiB and a parsed-source budget of 512 KiB (shortcode expansion included); a render past either, or one whose matches pattern is past the regular expression allowance, returns a Tool error instead of a cut-off render. Ordinary pages and the editor's live preview have no such budget. A request is refused up front when its starting message alone does not fit the token budget, or when the selected model is known not to support tool calling. A new Turn does not start when it could exceed the budget, but the tokens a Turn actually uses can exceed its estimate. Each provider call uses the model and reasoning setting of the call profile for the request's kind, and that profile's output limit and timeout are upper bounds: the output limit is reduced to what the remaining token budget allows, and the timeout to the time left before the run deadline.

Who can run one. The permission gate is the same as for classic mode. An account confined to a Group's subtree is refused with 403 ("Generation runs are not available to group-limited accounts"), a dry run included. An account has at most 2 runs in progress; a third request is refused with 429. With authentication disabled, every request is the administrator, so the limit, and who may finish a run, is counted per client IP address (the first X-Forwarded-For address, else X-Real-IP, else the connection's address). With authentication enabled it is counted per user. Access is checked again around every Turn and just before the draft is released: if the account is disabled, demoted or newly confined during the run, the run stops and neither the draft nor the transcript is returned. The answer is HTTP 403, or, when the event stream has already started, a final error event whose status is 403.

API. A generateTemplate request with Accept: text/event-stream is answered with server-sent events once the run reaches its first Turn (run, turn, tool, submission, usage, then a final result or error); errors found earlier keep their ordinary status codes. Without that header the response is one JSON object, which adds stopReason, submitted and transcript in harness mode. The request accepts previewMRQL and previewPlugins booleans, and privacyOff (see Privacy mode). POST /v1/{category|resourceCategory|noteType}/generateTemplate/finish with {"runId": "<id from the run event>"} is Finish now; an unknown run and another account's run both answer 404. The OpenAPI document lists the events.

Privacy mode​

Privacy mode replaces the values stored in your data with Placeholders before a request reaches the provider. It applies to every template generation request, in harness and classic mode alike, and it is on by default: the Review what will be sent dialog opens with a Privacy mode box ticked, first among its options, on every request. Nothing is remembered between requests.

What is masked. Every value read from your database: names, descriptions, Meta values, tags, owners, relation targets, note block content, hashes, storage locations, URLs, share tokens, revision labels, partial descriptions and dates. This covers the sample values in the starting message, every Tool result, and the entity a preview renders against, including the rows an [mrql] shortcode returns in a preview. Numbers, booleans and IDs pass through. A Meta value that equals an enum or const value of its own field in the schema stays readable.

What is not masked. Template source, partial source, the slot content of revisions, field names and Meta keys, the Meta JSON Schema and section layout, the names and Custom* fields of Categories, Resource Categories and Note Types, the names of relation types, the names of partials (their descriptions are masked), the type/subtype of a resource's content type (parameters are dropped, and a content type that is not a plain lower-case type/subtype is masked), the type of a note block, and your request are sent as written. Text you typed literally into a template slot is therefore sent too.

Placeholders. A Placeholder tells the model the shape of a value and nothing else, for example ⟦k7·text 3 · 1 line · ~50 chars⟧: a two-character tag, the kind (text, url, email or date), a number, whether the value is one line or several, and a rounded length. A date reads ⟦k7·date 2⟧. Equal values within one request share one Placeholder. A rendered preview cannot hold a Placeholder in a date field, so every native time field on the previewed entity (created, updated and similar) is the stand-in instant 2001-02-03T04:05:06Z, and the starting message says so. Dates elsewhere are date Placeholders: date-shaped strings in Meta and the StartDate and EndDate of the sample projections. [property path="URL"] renders a URL as https://placeholder.invalid/<tag>-url-<n>, which is another spelling of that URL's Placeholder.

Drafts never contain a Placeholder. Nothing maps a Placeholder back to a value. A submission that contains one the request issued is refused with a message to reference the field with [meta] or [property] instead. If the final draft would still contain one, that field is returned empty, listed in the response's withheldFields, and given an error issue. A template and its CSS are withheld together, the review panel says the field was withheld because it contained a Placeholder, and Apply is not offered for it.

Previews under Privacy mode. [mrql] previews stay available, with their results masked. Plugin shortcode previews are not: the plugin box in the dialog is disabled with an explanation, ticking Privacy mode unticks it, and a request that asks for both is refused with 400 ("plugin previews are not available in Privacy mode"). A preview of [mrql saved=...] (and the saved forms of [using], [conditional] and [each]) renders "saved queries are not available in Privacy mode", because a saved query's text and scope can carry stored values. An inline query that fails renders "the query failed; details are hidden in Privacy mode; use check_mrql to check its syntax", except when the query is unavailable, which keeps its inert rendering.

The guard. Masking is applied where data is read. As a second line, every outgoing request is scanned for the real values the request has masked (values of four or more characters, compared case-insensitively, unless the same text also appears in readable content such as your template source). A match stops the run before that request is sent: the stop reason is privacy_guard, there is no draft, even if the model had already submitted fields in earlier Turns, the transcript marks the blocked Turn's messages as not sent, and the response is HTTP 500 ("Privacy mode stopped a request that contained an entity value. Nothing was sent"). A request with more than 20,000 distinct masked values, 4 MiB of values or a single value over 256 KiB fails with "too much entity data for Privacy mode" instead of sending a partial result.

Seeing the real values. The dialog and the Transcript show Placeholders. Each Placeholder carries a tooltip with its value, and one Show real values button per surface (the dialog, and the Transcript) replaces every Placeholder with Placeholder = value; it is a toggle that reports its state. The server sends this legend to your browser only. It is not stored, logged or sent to the provider, it is dropped together with the transcript when an account's access changes during a run, and the browser clears it when the dialog closes, when the dialog is refreshed, and when the run panel clears its transcript.

Turning it off. Unticking the box repeats the dry run, so the dialog shows real values, and the request carries privacyOff: true. The choice is part of what you approve: a request whose privacy state differs from the reviewed one is refused with 409 and the status offers Review again.

Locking it on. The ai_template_privacy_mode runtime setting is per-run (the default) or always. With always the box is ticked and disabled, marked "Required by the administrator", and the server refuses a request with privacyOff set, a dry run included, with 400 ("Privacy mode is required on this server").

Supporting endpoints​

These editor tools are backed by these API endpoints:

EndpointPurpose
GET /v1/shortcodes/docsMachine-readable catalogue of the built-in shortcodes plus enabled plugin shortcodes. Powers lint and autocomplete.
POST /v1/shortcodes/lintLinting of shortcode markup with no shortcode or plugin execution and no database access; MRQL queries are parsed and their SQL is built without a connection.
POST /v1/{category|resourceCategory|noteType}/previewTemplateRenders a slot against an entity. Gated like the corresponding template save.
POST /v1/{category|resourceCategory|noteType}/generateTemplateDrafts a slot, the Meta JSON Schema, or a whole template from a natural-language prompt. Requires the configured template provider's model and key; gated like the corresponding template save.
POST /v1/{category|resourceCategory|noteType}/templateToolRuns one read Tool of a Generation run (lint, preview, check_mrql, entity, template, revision, partial and shortcode-doc reads) outside a run, for clients that edit templates themselves, such as the MCP template tools. Same executor and validation as a run; gated like the template save; refused for group-limited accounts.
POST /v1/{category|resourceCategory|noteType}/templateGuideThe reference a Generation run's model starts from (shortcode, plugin and MRQL references, partials, the carrier's identity, layout, Meta JSON Schema, samples and, with slot, its current content), without the parts about the run itself, plus the Tools' argument schemas.
POST /v1/{category|resourceCategory|noteType}/generateTemplate/finishFinish now for a live Generation run: makes its next Turn the last. Only the account that started the run can; gated like generateTemplate.

Reusing templates​

Three tools cut duplication across category templates: reusable partials, per-form copy/export/import, and starter presets.

Template partials​

A template partial is a named, reusable snippet of HTML plus shortcodes, managed under Template Partials (admin only). Reference one from any slot with:

[partial name="status-badge"]

The partial expands with the including entity's context, so its own [meta], [conditional], [mrql], and [each] shortcodes resolve against that entity. An unknown name renders an HTML comment instead of leaking the raw shortcode, and recursive partials terminate at the depth limit. Writes are admin-only because a partial expands inside every carrier's templates, including admin-managed Category surfaces; reads are open.

Copy, export, and import bundles​

The Reuse & Presets panel on each edit form fills the form without saving (nothing is written until you submit). The panel is closed when the form loads; click its title to open it. It opens by itself to show the notice when the form is opened with a revision to load:

  • Copy from… fills the slots from another category, of the same carrier or a different one. Cross-carrier copies fill the shared fields (the twelve slots every carrier has: Header, Detail Footer, Sidebar, Summary, Panel Summary, Avatar, Hover Card, List Header, List Footer, MRQL Result, Entity Picker Result and CSS, plus the Meta JSON Schema) and skip Section Config, whose shape differs per carrier.
  • Export bundle downloads the current editor contents as a .json bundle (schema version 1). It exports unsaved edits, so it doubles as a backup before experimenting.
  • Import bundle loads a bundle back into the form, warning on a carrier mismatch (then filling shared fields only) and rejecting a newer bundle schema version.

A bundle is a UI convenience, not part of the group export/import archive contract. A bundle that references [partial name="x"] imports fine; the linter flags the reference if that partial does not exist.

Starter presets​

The Start from preset picker offers a few ready-made templates (a project dashboard, a media collection, a contact card, and a reading log) that exercise the shortcode language. Applying a preset routes through the same client-side import path as a bundle, filling the form for review before you save.

Native plugin controls​

Prefer [meta path="field" editable=true] for schema-backed values. It supplies labels, enum colours, saving, read-only share rendering and morph handling. Use plugin controls for semantics the metadata editor cannot express, such as allocating an order key when a task moves.

Load a plugin's static script from its taxonomies' CustomHeader and CustomListHeader when only those surfaces need it. Keep shared styling in CustomCSS so native cards and public shares retain their styling without executing plugin Lua. Wide note display renders CustomHeader, CustomDetailFooter, CustomSidebar, and all note detail plugin slots. A note-type detail page also loads CSS for its displayed note cards.

A custom element with data-morph-client-owned keeps its client-rendered children during host page refreshes. Its attributes are still patched, and refreshFromMorph(toElement) can reconcile the new attributes.

Entity picker result templates​

Group Categories, Note Types and Resource Categories each offer CustomEntityPickerResult and CustomEntityPickerResultCSS. The HTML replaces only result content, not the host's checkbox/radio, selection state or keyboard controls. Leave the HTML empty for the default name, tags, thumbnail, owner and category/type presentation where available; it does not fall back to CustomSummary.

Use HTML and shortcodes, not Pongo2 or Alpine directives. Keep names and identifying properties readable. For example, on a group Category:

<div class="picker-person">
<a href="/group?id=[property path='ID']" target="_blank" rel="noopener noreferrer">[property path="Name"] <span class="sr-only">(opens in a new tab)</span></a>
<span>[property path="Category.Name"]</span>
</div>

Put matching styles in the companion field:

.entity-picker-result .picker-person { display: grid; gap: 0.25rem; }

The picker loads shared CustomCSS followed by CustomEntityPickerResultCSS. These are global styles, not a CSS sandbox; target .entity-picker-result and use distinctive class names. Copy/export/import template tools preserve both fields. The CLI exposes --custom-entity-picker-result and --custom-entity-picker-result-css on create and edit for all three carriers. The corresponding -file flags read UTF-8 HTML/CSS; an empty file or explicit empty inline value clears a slot on edit. A failed custom result is logged and falls back to default content. Styles are replaced on page/step changes and removed on close. See Entity Picker for pagination, nested filter browsing and confirmation semantics.

Companion stylesheets​

Every HTML template slot has its own global CSS companion, such as CustomMRQLResultCSS for CustomMRQLResult. The editor groups each template and stylesheet together. A single shared prompt and Generate button above each pair creates or modifies both fields together, using the current unsaved values as context. Whole-template generation also enforces complete pairs. Direct generation API requests targeting an HTML slot or companion CSS are treated as paired requests and return both fields in slots, including explicit empty values when clearing content. Shared CustomCSS and metadata schema generation remain independent.

Companion styles use the same page-level rendering and category deduplication as CustomCSS, following shared CustomCSS in the cascade. Use distinctive class names: these rules are global, not automatically scoped to the paired HTML. Public note shares include only CustomHeaderCSS and shared CustomCSS, and only when template sharing is enabled. Copy, bundle export/import, archive transfer, and CLI --custom-…-css flags preserve companion fields.