From ec0dd58271eabd0dd9fa12fbf51f5b46b8ceb014 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 21 Mar 2023 23:28:38 -0300 Subject: data steps: album additional files list This is WIP but seems to be working! Pretty big test of the new html.template system, which needed some extension here. --- src/util/html.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/util/html.js') diff --git a/src/util/html.js b/src/util/html.js index 63d7c1cf..e808eefa 100644 --- a/src/util/html.js +++ b/src/util/html.js @@ -411,8 +411,9 @@ export class Template { export class Slot { #defaultTag = new Tag(); + #handleContent = null; - constructor(template, slotName, defaultContent) { + constructor(template, slotName, defaultContentOrHandleContent) { if (!template) { throw new Error(`Expected template`); } @@ -423,7 +424,12 @@ export class Slot { this.template = template; this.slotName = slotName; - this.defaultContent = defaultContent; + + if (typeof defaultContentOrHandleContent === 'function') { + this.#handleContent = defaultContentOrHandleContent; + } else { + this.defaultContent = defaultContentOrHandleContent; + } } set defaultContent(value) { @@ -447,6 +453,14 @@ export class Slot { } toString() { - return this.content.toString(); + return this.valueOf().toString(); + } + + valueOf() { + if (this.#handleContent) { + return this.#handleContent(this.content); + } else { + return this.content; + } } } -- cgit 1.3.0-6-gf8a5