Stamp

<p:stamp> emits the value of one or more Context entries into the document at the point where it sits. It is the mechanism that places a computed value — most often the result of an Expression Binding — into the rendered page as HTML.

stamp is a built-in Method on the Pagelove namespace (https://pagelove.org/1.0); <p:stamp> is a Method Element that invokes it. Like an Include, a stamped value keeps its origin identity, so it can be written through with PUT, POST, and DELETE — see Interaction with HTTP Document Mutation.

When to use

A binding computes a value and exposes it under a name in Context, but a binding by itself does not render anything. Reach for <p:stamp> to surface that value where you want it to appear. Common shapes:

To render a list of items one element each, use Templating instead; stamp emits the named values as-is.

Form

<html xmlns:p="https://pagelove.org/1.0">
  <body>
    <p:stamp greeting></p:stamp>
  </body>
</html>

Two ingredients:

  1. An xmlns declaration binding a prefix (p) to the Pagelove namespace https://pagelove.org/1.0.
  2. A <p:stamp> element whose attribute names are the Context keys to emit. <p:stamp greeting> emits Context.greeting; <p:stamp greeting subtitle> emits both. The attribute values are ignored — only the names matter.

The xmlns declaration may live on <html>, <body>, or any ancestor of the <p:stamp> element.

How a value reaches Context

stamp reads Context[name] for each named attribute. A value gets into Context during composition by:

A <p:stamp> must appear after whatever wrote the value it names, in composition (tree-walk) order.

How the result is emitted

For the named keys, stamp collects each non-null Context value and returns:

Named values present Result
None (all null/absent) null — the <p:stamp> element is removed from the tree.
Exactly one That value.
More than one A list of the values, in attribute order.

Because the stamp method declares returns https://pagelove.org/Element, the returned value is handled by the method-element result rules: an element (or list of elements) is spliced in place of <p:stamp> and composition recurses into it; a scalar is inserted as text.

Routing a stamped instance

When a stamped value is a schema instance whose schema declares a @key property, the key is emitted as the spliced root element's id, so the instance remains addressable by #<key-value> inside the containing document.

Interaction with HTTP Document Mutation (PUT, POST & DELETE)

Like an Include, a stamped fragment retains its origin identity — the resource and element it was stamped from.

When a client performs a mutating HTTP request (PUT, POST, or DELETE) targeting an element that originated from a <p:stamp>:

For example, a DELETE addressed at a record stamped under <p:stamp currentuser> deletes the origin record, not the page that stamped it. This makes a stamped value a first-class, HTTP-addressable view of its source, not a render-time snapshot.

This write-through also applies when the stamping page is served from a parameterized route: a selector write to a stamped element on a concrete route URL (e.g. POST a comment to /posts/hello-world.html, where the page is the template /posts/:slug.html) resolves the route, composes the stamped record, and routes the write to its origin — just as for a literal page. Authorization is checked on the concrete route page the request is addressed to, not the origin data file.

Error cases

Condition Result
The p prefix is unbound, or bound to a URI other than https://pagelove.org/1.0 <p:stamp> is not recognised as a method element; dispatch fails (see Method Elements).
A named key has no Context value That key contributes nothing; if every named key is absent, the element is removed.
A namespace other than stamp's is invoked on the Pagelove prefix (e.g. <p:unknown>) HTTP 500: unknown method '<name>' on Pagelove namespace.

Example

A page binds a value with an Expression Binding and stamps it into <main>. The schema for stamp is built in, so no schema declaration is needed.

Say /stamp-demo.html contains

<!DOCTYPE html>
<html xmlns:e="https://pagelove.org/Binding/Sessel" xmlns:p="https://pagelove.org/1.0">
  <body e:greeting="'hello from a binding'">
    <main>
      <p:stamp greeting></p:stamp>
    </main>
    <div hidden itemscope itemtype="https://pagelove.org/AuthorizationRule">
      <meta itemprop="actor" content="*">
      <meta itemprop="resource" content="/*">
      <meta itemprop="method" content="GET">
      <meta itemprop="action" content="allow">
    </div>
  </body>
</html>
GET /stamp-demo.html HTTP/2
Host: 127.0.0.1
Range: selector=main
HTTP/2 206
content-range: selector main

hello from a binding

The e:greeting binding writes Context.greeting; <p:stamp greeting> reads it and is replaced by its value.

See also