The Prototype (Template Cloning)
Cloning existing DOM fragments to rapidly spawn entities without server roundtrips.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Prototype
ARCANUM SCHOOL: Illusion // Duplication
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
<!-- The prototype template lies dormant, invisible to the naked eye. -->
<template id="minion-prototype">
<div class="minion-entity" hx-post="/api/minion/activate" hx-trigger="click">
<span class="status">Dormant Minion</span>
</div>
</template>
<!-- Hyperscript is often paired with HTMX for rapid client-side cloning -->
<button _="on click
put innerHTML of #minion-prototype
at end of #minion-army">
Clone Minion
</button>
<div id="minion-army" class="swarm-container">
<!-- Cloned entities manifest here -->
</div>
While HTMX primarily deals with server-driven state, the Prototype pattern frequently manifests on the client side when sheer speed is required. By utilizing the HTML <template> element as an arcane blueprint, we can stamp out copies of a DOM node instantly.
When paired with a tool like hyperscript (or standard JavaScript), the client can duplicate the dormant shell. These shells are pre-inscribed with HTMX attributes (hx-post), meaning that once they are cloned into the active DOM, they are fully capable of phoning home to the server to truly awaken. It is a perfect marriage of client-side illusion and server-side substance.
Runic Tags:
#htmx
#hyperscript
#prototype
#cloning
#templating