diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-06-12 13:06:39 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-06-18 22:56:07 -0300 |
commit | 01c674b5225c1460b8dd05bbf8b657a6c578860a (patch) | |
tree | e3631b9756712dad44e89ab9cfbdf1d58b967661 /src | |
parent | d40e3b561e6354cd329a43d871ec73cd6526cee4 (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/util/html.js | 12 |
1 files 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 += `<span class="blockwrap">`; blockwrapClosers += `</span>`; } |