@saltcorn/markup
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -30,2 +30,6 @@ const { a, input, div, ul, text } = require("./tags"); | ||
); | ||
expect(div({ class: ["foo", " "] }, 5)).toBe('<div class="foo ">5</div>'); | ||
expect(input({ class: ["foo", " "] })).toBe('<input class="foo ">'); | ||
expect( | ||
@@ -32,0 +36,0 @@ div({ class: ["foo bar", "", undefined, null, false, "baz"] }, 5) |
{ | ||
"name": "@saltcorn/markup", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "", | ||
@@ -12,3 +12,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"contractis": "^0.0.5", | ||
"contractis": "^0.0.6", | ||
"xss": "^1.0.6" | ||
@@ -25,3 +25,3 @@ }, | ||
}, | ||
"gitHead": "1725443990ecd751fed7549ed73fdb8aee4b0ed0" | ||
"gitHead": "4c4b8e7d7ebc5a703b8c9f7c1527b59694238d71" | ||
} |
30
tags.js
const xss = require("xss"); | ||
const ppClasses = cs => | ||
typeof cs === "string" ? cs : !cs ? "" : cs.filter(c => c).join(" "); | ||
const ppAttrib = ([k, v]) => | ||
typeof v === "boolean" | ||
? v | ||
? k | ||
: "" | ||
: typeof v === "undefined" | ||
? "" | ||
: k === "class" | ||
? `class="${ppClasses(v)}"` | ||
: `${k}="${v}"`; | ||
const mkTag = (tnm, forceStandAloneClosingTag) => (...args) => { | ||
@@ -7,16 +20,2 @@ var body = ""; | ||
const ppClasses = cs => | ||
typeof cs === "string" ? cs : !cs ? "" : cs.filter(c => c).join(" "); | ||
const ppAttrib = ([k, v]) => | ||
typeof v === "boolean" | ||
? v | ||
? k | ||
: "" | ||
: typeof v === "undefined" | ||
? "" | ||
: k === "class" | ||
? `class="${ppClasses(v)}"` | ||
: `${k}="${v}"`; | ||
const argIter = arg => { | ||
@@ -45,3 +44,3 @@ if (typeof arg === "undefined" || arg === null || arg === false) { | ||
const attribs = Object.entries(kvs) | ||
.map(([k, v]) => `${k}="${v}"`) | ||
.map(ppAttrib) | ||
.join(" "); | ||
@@ -76,2 +75,3 @@ return `<input ${attribs}>`; | ||
header: mkTag("header"), | ||
footer: mkTag("footer"), | ||
section: mkTag("section"), | ||
@@ -78,0 +78,0 @@ tr: mkTag("tr"), |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20557
681
+ Addedcontractis@0.0.6(transitive)
- Removedcontractis@0.0.5(transitive)
Updatedcontractis@^0.0.6