diff options
| author | (quasar) nebula <qznebula@protonmail.com> | 2026-02-09 17:28:21 -0400 |
|---|---|---|
| committer | (quasar) nebula <qznebula@protonmail.com> | 2026-02-09 17:28:21 -0400 |
| commit | 3c98e89daad1e312907c6f5f614b44b38f65408e (patch) | |
| tree | 69dee2add4069c8331dae0880c266bee7b6313a6 /src/html.js | |
| parent | df5ff85bdc2d56cbb8ef4d104dd7b82867ecca73 (diff) | |
data, content, html: FlashAct.nameHTML
Diffstat (limited to 'src/html.js')
| -rw-r--r-- | src/html.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/html.js b/src/html.js index 4cac9525..cde86a5c 100644 --- a/src/html.js +++ b/src/html.js @@ -296,6 +296,14 @@ export function isBlank(content) { return false; } +export function ifelse(options) { + for (const option of options) { + if (!isBlank(option)) return option; + } + + return blank(); +} + export const validators = { isBlank(value) { if (!isBlank(value)) { @@ -411,6 +419,37 @@ export function escape(string, {attribute = false} = {}) { return string; } +export function permit(string, adjustment) { + if (typeof string === 'string') { + if (string.length) { + return new Tag(null, null, adjust(string, adjustment)); + } else { + return blank(); + } + } else if (string === null) { + return blank(); + } else { + throw new TypeError(`expected string or null`); + } +} + +export function adjust(string, { + inline = false, + strip = false, +} = {}) { + // zalgo + + if (inline || strip) { + string = string.replace(/<br\/?>/g, ' '); + } + + if (strip) { + string = striptags(string); + } + + return string; +} + export class Tag { #tagName = ''; #content = null; |