edge:redact

The edge:redact boolean global attribute replaces the element with a comment in the deployed page. The comment spans the same lines as the element, so line numbers stay the same.

Syntax

html
<template o:=About.html edge:redact>…</template>
<script edge:redact>console.log('playground only')</script>
<iframe src=About.html edge:redact></iframe>

Value

Boolean

The attribute needs no value: its presence turns redaction on for the element.

Description

On deploy, the element becomes <!--REDACTED, then the line breaks of the element minus one, then -->. There is no space after <!--.

Element in the sourceIn the deployed page
A one-line element<!--REDACTED-->
An element that spans three lines<!--REDACTED, an empty line, then -->: a comment on three lines.

The element still produces its exports and assets. An element with o: or worker:fs is extracted first, and its own body is not redacted, so <template o:=Page.html edge:redact> serves Page.html at its URL and then vanishes from the root.

The attribute applies anywhere: inside <template> content, and inside the export bodies of other elements. edge:remove runs before edge:redact, so an element with both is removed.

In the playground neither attribute does anything: the output renders and runs the element. Code: Size shows a ⚑ count of the elements that are stripped or redacted on deploy.

Usage notes

Redaction is not secrecy

Warning: edge:redact only changes the served HTML. The deployed source, opened with ?, still contains the element, and so does every saved version. The source is public unless the deployment has access rules. See Keeping secrets out.

Line counts

The number of lines comes from the serialized element, not from your source text. Line breaks between attributes inside a multi-line start tag are lost: a start tag that spans three lines before its content counts as one. A newline character reference such as &#10; adds a line. Keep start tags on one line when later line numbers in the deployed page must match the source.

Elements inside exported files

RTEdge.net builds the body of an exported element from a cleaned copy. A nested edge:redact element becomes a <!--REDACTED--> comment in that file, a nested edge:remove element becomes blank lines, and RTCode attributes are stripped. The playground keeps nested elements and attributes in such bodies.

Pages in templates

<template o:=Page.html edge:redact> is the pattern behind a multi-page site: the page is published at its own URL and hidden from the root. See Building a multi-page site.

A root with nothing left

On a host-root route with an edge worker, a root that holds only whitespace and comments after redaction is answered by the worker instead. Do not rely on this on path routes.

On deploy

edge:redact is stripped from the served page together with the other edge: attributes. The deployed source keeps it.

Examples

A page that exists only at its own URL

html
<template o:=About.html edge:redact>
<meta charset=utf-8><title>About</title>
<h1>About</h1>
</template>
<iframe src=About.html></iframe>

The playground shows the page in the frame.

What the deployed root holds

On RTEdge.net the template is published as /About.html, and the root holds this instead of the template, a comment on the same four lines:

plain
<!--REDACTED


-->
<iframe src="About.html"></iframe>

Cleaning an export body

html
<div o:=card.html edge:redact class=x h:cache-control=no-cache>Hi
<span edge:remove>x</span></div>

The exported body

RTEdge.net serves /card.html with the header cache-control: no-cache and this body: the RTCode attributes and the removed span are gone, and the root hides the element.

plain
<div class="x">Hi
</div>

Specifications

Not part of any specification. edge:redact is an RTCode.io and RTEdge.net feature.

It builds on these standards:

Specification
HTML Standard: Comments
HTML Standard: The template element

Availability

FeaturePlaygroundRTEdge.netNotes
Replacing the element with a commentNo effectYesApplied on deploy.
Exports from the elementYesYesThe export is produced before the element is hidden.
Count of redacted elements in Code: SizeYesNoA ⚑ count.
Agent File Sync (Agent Folder Share)YesNoSynced files hold the authored source, redacted elements included. Chrome or Edge on desktop.

See also