boxwood 0.61.5 → 0.63.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 +28 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const { join } = require('path')
|
|
2
|
+
const { readFileSync } = require('fs')
|
|
1
3
|
const csstree = require('css-tree')
|
|
2
4
|
const toHash = require('string-hash')
|
|
3
5
|
|
|
@@ -174,6 +176,9 @@ const render = (input, escape = true) => {
|
|
|
174
176
|
if (input.name === 'fragment') {
|
|
175
177
|
return render(input.children)
|
|
176
178
|
}
|
|
179
|
+
if (input.name === 'raw') {
|
|
180
|
+
return render(input.children, false)
|
|
181
|
+
}
|
|
177
182
|
if (SELF_CLOSING_TAGS.includes(input.name)) {
|
|
178
183
|
if (input.attributes) {
|
|
179
184
|
return `<${input.name} ` + attributes(input.attributes) + '>'
|
|
@@ -204,6 +209,16 @@ const fragment = (children) => {
|
|
|
204
209
|
return { name: 'fragment', children }
|
|
205
210
|
}
|
|
206
211
|
|
|
212
|
+
const raw = (children) => {
|
|
213
|
+
return { name: 'raw', children }
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
raw.load = function () {
|
|
217
|
+
const path = join(...arguments)
|
|
218
|
+
const content = readFileSync(path, 'utf8')
|
|
219
|
+
return raw(content)
|
|
220
|
+
}
|
|
221
|
+
|
|
207
222
|
const tag = (a, b, c) => {
|
|
208
223
|
if (a && b && c) {
|
|
209
224
|
const name = a
|
|
@@ -258,6 +273,12 @@ function css(inputs) {
|
|
|
258
273
|
}
|
|
259
274
|
}
|
|
260
275
|
|
|
276
|
+
css.load = function () {
|
|
277
|
+
const path = join(...arguments)
|
|
278
|
+
const content = readFileSync(path, 'utf8')
|
|
279
|
+
return css`${content}`
|
|
280
|
+
}
|
|
281
|
+
|
|
261
282
|
function js(inputs) {
|
|
262
283
|
let result = ''
|
|
263
284
|
for (let i = 0, ilen = inputs.length; i < ilen; i += 1) {
|
|
@@ -274,6 +295,12 @@ function js(inputs) {
|
|
|
274
295
|
}
|
|
275
296
|
}
|
|
276
297
|
|
|
298
|
+
js.load = function () {
|
|
299
|
+
const path = join(...arguments)
|
|
300
|
+
const content = readFileSync(path, 'utf8')
|
|
301
|
+
return js`${content}`
|
|
302
|
+
}
|
|
303
|
+
|
|
277
304
|
const node = (name) => (options, children) => tag(name, options, children)
|
|
278
305
|
const doctype = node('!DOCTYPE html')
|
|
279
306
|
|
|
@@ -420,6 +447,7 @@ module.exports = {
|
|
|
420
447
|
doctype,
|
|
421
448
|
escape: escapeHTML,
|
|
422
449
|
fragment,
|
|
450
|
+
raw,
|
|
423
451
|
css,
|
|
424
452
|
js,
|
|
425
453
|
...nodes,
|