From d6ff52b3f7d3096412a53116c49f5120a082cbf0 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 12 Jun 2024 13:06:39 -0300 Subject: html: #stringifyContent: always resolve template items This makes onlyIfSiblings on template content work properly. It should also enable templates which return strings directly to be treated as text for the purposes of chunkwrap, have own blockwrap processed, etc. --- src/util/html.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/util/html.js b/src/util/html.js index 594966ed..6efedb31 100644 --- a/src/util/html.js +++ b/src/util/html.js @@ -649,10 +649,12 @@ export class Tag { } for (const [index, item] of contentItems.entries()) { - let itemContent; + const nonTemplateItem = + Template.resolve(item); + let itemContent; try { - itemContent = item.toString(); + itemContent = nonTemplateItem.toString(); } catch (caughtError) { const indexPart = colors.yellow(`child #${index + 1}`); @@ -681,12 +683,12 @@ export class Tag { continue; } - if (!(item instanceof Tag && item.onlyIfSiblings)) { + if (!(nonTemplateItem instanceof Tag) || !nonTemplateItem.onlyIfSiblings) { seenSiblingIndependentContent = true; } const chunkwrapChunks = - (typeof item === 'string' && chunkwrapSplitter + (typeof nonTemplateItem === 'string' && chunkwrapSplitter ? itemContent.split(chunkwrapSplitter) : null); @@ -726,7 +728,7 @@ export class Tag { // itemContent check. They also never apply at the very start of content, // because at that point there aren't any preceding words from which the // blockwrap would differentiate its content. - if (item instanceof Tag && item.blockwrap && content) { + if (nonTemplateItem instanceof Tag && nonTemplateItem.blockwrap && content) { content += ``; blockwrapClosers += ``; } -- cgit 1.3.0-6-gf8a5