boxwood 0.78.0 → 0.80.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/README.md +3 -3
- package/index.js +8 -4
- package/package.json +9 -7
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ const { compile } = require("boxwood")
|
|
|
42
42
|
const { join } = require("path")
|
|
43
43
|
// ...
|
|
44
44
|
const path = join(__dirname, "index.js")
|
|
45
|
-
const { template } =
|
|
45
|
+
const { template } = compile(path)
|
|
46
46
|
// ...
|
|
47
47
|
const html = template({ foo: "bar" })
|
|
48
48
|
console.log(html)
|
|
@@ -121,13 +121,13 @@ const assert = require("node:assert")
|
|
|
121
121
|
const { compile } = require("boxwood")
|
|
122
122
|
|
|
123
123
|
test("banner renders a title", async () => {
|
|
124
|
-
const { template } =
|
|
124
|
+
const { template } = compile(__dirname)
|
|
125
125
|
const html = template({ title: "foo" })
|
|
126
126
|
assert(html.includes("<h1>foo</h1>"))
|
|
127
127
|
})
|
|
128
128
|
|
|
129
129
|
test("banner renders an optional description", async () => {
|
|
130
|
-
const { template } =
|
|
130
|
+
const { template } = compile(__dirname)
|
|
131
131
|
const html = template({ title: "foo", description: "bar" })
|
|
132
132
|
assert(html.includes("<h1>foo</h1>"))
|
|
133
133
|
assert(html.includes("<p>bar</p>"))
|
package/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
const { join } = require("path")
|
|
2
2
|
const { readFileSync } = require("fs")
|
|
3
3
|
const csstree = require("css-tree")
|
|
4
|
-
const toHash = require("string-hash")
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
function compile(path) {
|
|
7
6
|
const fn = require(path)
|
|
8
7
|
return {
|
|
9
8
|
template() {
|
|
@@ -268,6 +267,11 @@ const tag = (a, b, c) => {
|
|
|
268
267
|
}
|
|
269
268
|
}
|
|
270
269
|
|
|
270
|
+
let number = 1
|
|
271
|
+
function sequence() {
|
|
272
|
+
return number++
|
|
273
|
+
}
|
|
274
|
+
|
|
271
275
|
function css(inputs) {
|
|
272
276
|
let result = ""
|
|
273
277
|
for (let i = 0, ilen = inputs.length; i < ilen; i += 1) {
|
|
@@ -279,13 +283,13 @@ function css(inputs) {
|
|
|
279
283
|
result += input
|
|
280
284
|
}
|
|
281
285
|
}
|
|
282
|
-
const hash =
|
|
286
|
+
const hash = sequence()
|
|
283
287
|
const tree = csstree.parse(result)
|
|
284
288
|
const classes = {}
|
|
285
289
|
|
|
286
290
|
csstree.walk(tree, (node) => {
|
|
287
291
|
if (node.type === "ClassSelector") {
|
|
288
|
-
const name =
|
|
292
|
+
const name = `${node.name}_${hash}`
|
|
289
293
|
classes[node.name] = name
|
|
290
294
|
node.name = name
|
|
291
295
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "boxwood",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.80.0",
|
|
4
4
|
"description": "Compile HTML templates into JS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
"homepage": "https://github.com/buxlabs/boxwood#readme",
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"benchmark": "2.1.4",
|
|
50
|
-
"c8": "^
|
|
51
|
-
"express": "^4.
|
|
50
|
+
"c8": "^10.1.2",
|
|
51
|
+
"express": "^4.21.0",
|
|
52
52
|
"handlebars": "^4.7.8",
|
|
53
|
-
"jsdom": "^
|
|
53
|
+
"jsdom": "^25.0.0",
|
|
54
54
|
"mustache": "^4.2.0",
|
|
55
|
-
"underscore": "^1.13.
|
|
55
|
+
"underscore": "^1.13.7"
|
|
56
56
|
},
|
|
57
57
|
"standard": {
|
|
58
58
|
"ignore": [
|
|
@@ -62,7 +62,9 @@
|
|
|
62
62
|
]
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"css-tree": "^
|
|
66
|
-
|
|
65
|
+
"css-tree": "^3.0.0"
|
|
66
|
+
},
|
|
67
|
+
"prettier": {
|
|
68
|
+
"semi": false
|
|
67
69
|
}
|
|
68
70
|
}
|