boxwood 0.71.1 → 0.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +32 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -171,7 +171,10 @@ const render = (input, escape = true) => {
|
|
|
171
171
|
return ""
|
|
172
172
|
}
|
|
173
173
|
if (Array.isArray(input)) {
|
|
174
|
-
return input
|
|
174
|
+
return input
|
|
175
|
+
.filter(Boolean)
|
|
176
|
+
.map((input) => render(input))
|
|
177
|
+
.join("")
|
|
175
178
|
}
|
|
176
179
|
if (typeof input === "number") {
|
|
177
180
|
return input.toString()
|
|
@@ -428,6 +431,34 @@ const nodes = [
|
|
|
428
431
|
return result
|
|
429
432
|
}, {})
|
|
430
433
|
|
|
434
|
+
function extension(path) {
|
|
435
|
+
const parts = path.split(".")
|
|
436
|
+
return parts[parts.length - 1].toLowerCase()
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function media(path) {
|
|
440
|
+
const type = extension(path)
|
|
441
|
+
return `image/${type === "jpg" ? "jpeg" : type}`
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
function base64({ content, path }) {
|
|
445
|
+
return `data:${media(path)};base64,${content}`
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
nodes.img.load = function () {
|
|
449
|
+
const path = join(...arguments)
|
|
450
|
+
const content = readFileSync(path, "base64")
|
|
451
|
+
return (options) => {
|
|
452
|
+
return nodes.img({ src: base64({ content, path }), ...options })
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
nodes.svg.load = function () {
|
|
457
|
+
const path = join(...arguments)
|
|
458
|
+
const content = readFileSync(path, "utf8")
|
|
459
|
+
return raw(content)
|
|
460
|
+
}
|
|
461
|
+
|
|
431
462
|
function classes() {
|
|
432
463
|
const array = []
|
|
433
464
|
for (let i = 0, ilen = arguments.length; i < ilen; i += 1) {
|