Paged.The open publishing system
The technical handbook
Templates

Paged Docs / Templates

Template fields

The open parts of a template — the engine's field kinds, the module field kinds of every built-in module, constraints, values, and what can be set today.

Tier: IntermediateIntermediateIIreferenceDraft

Reviewed against engine v0.74.2

A field swaps content, not design.

In short A field is an item (or a text variable) the template opens for filling. It has a name, a kind, an optional label, help text, group and required flag, and constraints. Filling a field grants exactly what that takes — a text field select and text.edit on its frame, an image field select and image.replace — and nothing else. Today text, variable, image and visibility fields can be set, and every built-in module contributes module fields for its own content; textRun, choice and data are listed but not yet settable.

Kinds

KindTargetValueGrants on the itemCan be set today
texta whole text frame's storytextselect, text.edityes
textRuna placeholder run inside a storytextselect, text.editnot yet
variablea custom text variable, wherever it is insertedtextselect, text.edityes
imagea graphic frame's picturea picture (by URI, or bytes through the editor)select, image.replaceyes
choicea property, one of an allowed listone of allowedselectnot yet
visibilityan item shown or hiddenon or offselect, item.visibilityyes
dataa paged.data bindinga record or a field of oneselect, text.edit, image.replacenot yet
modulea part of a module's content on the item (below)what the module's kind takesselect, document.metadata, and the kind's grantsyes, through its module

The author may grant more on an item through its allow list (for example text.style, or image.crop on an image field) and take permissions away with deny.

Module fields

A template may open part of a module's content: a sheet's cell, a paragraph of a placed .docx document, a drawing's colour, an edited image's picture. Such a field has the kind module; its module names the module's field kind, the module's own definition (a cell reference, a paragraph anchor, a layer name) and the permissions filling it takes:

{
  "v": 1,
  "data": {
    "field": {
      "name": "price",
      "kind": "module",
      "label": "Price",
      "module": {
        "kind": "media.paged.sheet.cell",
        "def": { "ref": "Prices!B2", "type": "number", "min": 0 },
        "grants": ["text.edit", "text.style"]
      }
    }
  }
}

The module that owns the kind reads and writes the value through its usual door, so the engine checks every write against the session's role as it checks its own: a module field is never a way around the policy. A refused value is answered in one sentence the form shows next to the field. The engine lists a module field in templateFields without a value and refuses it in setTemplateFields ("a module field is set through its module"); the editor's template form and paged template route it to its module instead.

The form shows the control the kind declares: text (one line or several), a number, a choice, a toggle, a picture, or a table.

ModuleField kindDefinitionForm controlWhat a value does
sheetmedia.paged.sheet.cell{ ref, type?, allowed?, min?, max? }text, number or choiceone cell's constant (Sheet!A1 or a defined name); a formula is refused
sheetmedia.paged.sheet.range{ ref, columns?, rows? }tablea range's values; rows: "fixed" or { min?, max? }
sheetmedia.paged.sheet.chartSource{ chart, allowed }choicewhich of the author's series lists a chart draws
docmedia.paged.doc.blockText{ anchor, frame? }texta paragraph's text, keeping its look; the anchor is a bookmark, a style and occurrence, or a block index
docmedia.paged.doc.mergeField{ name, frame? }textevery use of a .docx merge field
docmedia.paged.doc.listItems{ anchor, frame? }table, one columna list's items; new items copy the last item's look
drawmedia.paged.draw.paint{ channel, allowed?, target? }choicethe fill or stroke swatch
drawmedia.paged.draw.graphicStyle{ allowed?, targets? }choicethe graphic style
drawmedia.paged.draw.textOnPath{ path? }textthe text on a path
drawmedia.paged.draw.symbolChoice{ allowed? }choicewhich one-piece symbol an instance shows
imagemedia.paged.image.picture{ layer?, frame? }picturereplaces a layer's pixels; the adjustment layers above stay
imagemedia.paged.image.adjustmentPreset{ allowed, layer?, frame? }choiceone of the author's adjustment presets
imagemedia.paged.image.layerVisibility{ layer, frame? }togglea layer shown or hidden
slidemedia.paged.slide.placeholderText{ placeholder?, slide? }texta placeholder's text, keeping its formatting
slidemedia.paged.slide.visibility{ slide? }togglea slide shown or hidden
webmedia.paged.web.value{ name }texta web frame's {{doc.<key>}} value, as text
webmedia.paged.web.source{ lane }text, several linesthe frame's HTML (sanitised) or CSS
webmedia.paged.web.cssVar{ name, allowed? }choice, else texta CSS custom property
datamedia.paged.data.record{ query, label? }choicewhich record of a query fills the document
datamedia.paged.data.bindingValue{ binding }follows the bound propertya binding's value, pinned so a refresh keeps it
datamedia.paged.data.dataSet{ allowed? }choicewhich captured data set the document shows
datamedia.paged.data.variable{ name }follows the variablea property or visibility variable

paged template kinds lists the kinds the loaded modules offer. Some kinds need a permission granted document-wide in today's engine: a sheet field and a slide's visibility need document.metadata, text on a path needs text.edit, and a chart's source needs adding and deleting items; the field reports when it lacks one. The publish module (PDF) has no field kind yet: which page of a placed PDF a frame shows is planned. Each module's own documentation in the repository lists its limits (a table cell, a header or a picture in a .docx document cannot be a field yet, for example).

The definition

{
  "name": "headline",
  "kind": "text",
  "label": "Headline",
  "help": "Up to 30 characters",
  "group": "Front",
  "required": true,
  "constraints": { "maxLength": 30 }
}
  • name — the field's name; give the item the same name, so it can be addressed as frame[name="headline"].
  • label, help, group — what the form shows. The document's policy lists the form order by name.
  • Variable fields are declared in the document's policy, under variables, keyed by the text variable.

Constraints

ConstraintApplies toChecked today
requiredevery kindyes
maxLengthtextyes
maxLinestextcarried, not yet checked
patterntextcarried, not yet checked
overflow — refuse, shrink, allow-and-flagtextcarried, not yet checked
minPpi — minimum effective resolutionimagecarried, not yet checked
allowed — the allowed valueschoice—
fit — the fit applied after a picture is replacedimage—

Whether a text field's story is overset is reported with the field.

Values

Setting the engine's own kinds is one message, setTemplateFields, used alike by the editor's form, the embedding handle's setFieldValues and the paged template fill command:

[
  { "name": "headline",  "value": { "kind": "text",    "text": "Grand opening" } },
  { "name": "photo",     "value": { "kind": "image",   "uri": "https://example.com/shop.jpg" } },
  { "name": "showBadge", "value": { "kind": "visible", "visible": true } }
]
  • Every value is checked against its field (the kind, required, maxLength). If any value does not fit, none is set and the answer lists the problems (templateFieldsRefused).
  • The values that fit are lowered to one batch of ordinary edits: one undo step, and every edit checked against the session's permissions.
  • A text field's new text takes the style of the old text's first run — content, not design.

Reading values: the templateFields collection lists the fields in form order, each with its definition, its target, the story a text field edits, its current value (text, image by URI, visible) and whether its story is overset.

On this page