From f12890facba502805f03a64c76f386c4531abbcc Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 12 Jun 2023 14:51:08 -0300 Subject: html: new Stationery class for instantiating Templates --- src/util/html.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/util') diff --git a/src/util/html.js b/src/util/html.js index f5c1dee0..b75820e8 100644 --- a/src/util/html.js +++ b/src/util/html.js @@ -489,7 +489,10 @@ export class Template { #slotValues = {}; constructor(description) { - Template.validateDescription(description); + if (!description[Stationery.validated]) { + Template.validateDescription(description); + } + this.#description = description; } @@ -779,3 +782,23 @@ export class Template { return this.content.toString(); } } + +export function stationery(description) { + return new Stationery(description); +} + +export class Stationery { + #templateDescription = null; + + static validated = Symbol('Stationery.validated'); + + constructor(templateDescription) { + Template.validateDescription(templateDescription); + templateDescription[Stationery.validated] = true; + this.#templateDescription = templateDescription; + } + + template() { + return new Template(this.#templateDescription); + } +} -- cgit 1.3.0-6-gf8a5