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:
- Render a value computed by an
e:-prefixed Expression Binding inline. - Render an instance written into
Contextby an upstream method, so descendant routing can address it (see Routing a stamped instance).
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:
- An xmlns declaration binding a prefix (
p) to the Pagelove namespacehttps://pagelove.org/1.0. - A
<p:stamp>element whose attribute names are theContextkeys to emit.<p:stamp greeting>emitsContext.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:
- An Expression Binding —
e:greeting="…"evaluates the Sessel expression and writes the result toContext.greeting. - A Method that assigns
Context.<name> = …. The composition pipeline propagates a method'sContextmutations to later dispatches on the same page.
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>:
- The modification is applied to the origin resource, not the composed document the stamp appears in.
- Authorization is evaluated against the composed page the request is addressed to — the page where the stamp appears — not the origin. The origin resource therefore needs no rule of its own permitting the write (a rule on the composed page is both necessary and sufficient).
- Shape constraints are evaluated against the origin resource, where the mutation lands.
- Schema validation (cardinality and
@validate) is evaluated against the origin resource, where the mutation lands. A write through a page-only selector is checked at the selector that resolves in the origin, not at the one you sent, so a write that breaks a cardinality rule there is refused with422and nothing is written. - Concurrency control (ETags) is performed against the origin resource. Reading a stamped element through the composed page gives you the origin document's validator, so a conditional write through the page is checked against the origin. The validator names both what you were shown and what is stored, and only the stored half decides the write, so a schema read resolver that rewrites a property value does not stop you saving it back. If composition itself changed the element's markup on the way out — by stripping a namespace-prefixed attribute, for example — the conditional write is still refused with
412and ahttps://pagelove.org/Problem/RepresentationMismatchproblem item. See PUT.
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
PUT /stamp-demo.html HTTP/2
Host: 127.0.0.1
Content-Type: text/html
<!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
- Expression Binding — compute the value that
stampemits, and write it toContextunder a name. - Method Elements — the dispatch mechanism
<p:stamp>uses;stampis a built-in method on the Pagelove namespace. - Templating — render a list of items, one element each, rather than emitting a value as-is.
- Includes — pull a fragment from another document; shares the same origin-identity write-through semantics.
- Methods — declaring methods on a schema (
stampis the built-in one onhttps://pagelove.org/1.0).