From 9c11308ace82c024ddb0223d9ffeb742d86ad927 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 2 Jul 2022 15:21:24 -0300 Subject: htmlify album pages --- src/util/html.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/util/html.js') diff --git a/src/util/html.js b/src/util/html.js index 0ba923b3..338df71b 100644 --- a/src/util/html.js +++ b/src/util/html.js @@ -20,11 +20,18 @@ export const selfClosingTags = [ 'wbr', ]; -// Pass to tag() as an attri8utes key to make tag() return a 8lank string -// if the provided content is empty. Useful for when you'll only 8e showing -// an element according to the presence of content that would 8elong there. +// Pass to tag() as an attributes key to make tag() return a 8lank string if the +// provided content is empty. Useful for when you'll only 8e showing an element +// according to the presence of content that would 8elong there. export const onlyIfContent = Symbol(); +// Pass to tag() as an attributes key to make children be joined together by the +// provided string. This is handy, for example, for joining lines by
tags, +// or putting some other divider between each child. Note this will only have an +// effect if the tag content is passed as an array of children and not a single +// string. +export const joinChildren = Symbol(); + export function tag(tagName, ...args) { const selfClosing = selfClosingTags.includes(tagName); @@ -59,7 +66,11 @@ export function tag(tagName, ...args) { } if (Array.isArray(content)) { - content = content.filter(Boolean).join('\n'); + const joiner = attrs?.[joinChildren]; + content = content.filter(Boolean).join( + (joiner + ? `\n${joiner}\n` + : '\n')); } if (content) { -- cgit 1.3.0-6-gf8a5