boxwood 0.61.0 → 0.61.2
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 +12 -11
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -9,7 +9,7 @@ async function compile(path) {
|
|
|
9
9
|
const nodes = {}
|
|
10
10
|
const styles = []
|
|
11
11
|
const scripts = []
|
|
12
|
-
const
|
|
12
|
+
const walk = (node) => {
|
|
13
13
|
if (node.name === 'head') {
|
|
14
14
|
nodes.head = node
|
|
15
15
|
}
|
|
@@ -22,10 +22,12 @@ async function compile(path) {
|
|
|
22
22
|
node.ignore = true
|
|
23
23
|
}
|
|
24
24
|
if (Array.isArray(node)) {
|
|
25
|
-
node.forEach(
|
|
25
|
+
node.forEach(walk)
|
|
26
|
+
} else if (Array.isArray(node.children)) {
|
|
27
|
+
node.children.forEach(walk)
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
|
-
walk(tree
|
|
30
|
+
walk(tree)
|
|
29
31
|
if (nodes.head) {
|
|
30
32
|
if (styles.length > 0) {
|
|
31
33
|
nodes.head.children.push({
|
|
@@ -45,13 +47,6 @@ async function compile(path) {
|
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
function walk(tree, callback) {
|
|
49
|
-
callback(tree)
|
|
50
|
-
if (Array.isArray(tree.children)) {
|
|
51
|
-
tree.children.map((node) => walk(node, callback))
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
50
|
const ENTITIES = {
|
|
56
51
|
'&': '&',
|
|
57
52
|
'<': '<',
|
|
@@ -107,13 +102,19 @@ const BOOLEAN_ATTRIBUTES = [
|
|
|
107
102
|
'translate',
|
|
108
103
|
]
|
|
109
104
|
|
|
105
|
+
const ALIASES = {
|
|
106
|
+
className: 'class',
|
|
107
|
+
htmlFor: 'for'
|
|
108
|
+
}
|
|
109
|
+
|
|
110
110
|
const attributes = (options) => {
|
|
111
111
|
const result = []
|
|
112
112
|
for (const key in options) {
|
|
113
113
|
if (BOOLEAN_ATTRIBUTES.includes(key)) {
|
|
114
114
|
result.push(key)
|
|
115
115
|
} else {
|
|
116
|
-
|
|
116
|
+
const name = ALIASES[key] || key
|
|
117
|
+
result.push(name + '=' + '"' + options[key] + '"')
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
120
|
return result.join(' ')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "boxwood",
|
|
3
|
-
"version": "0.61.
|
|
3
|
+
"version": "0.61.2",
|
|
4
4
|
"description": "Compile HTML templates into JS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
]
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"css-tree": "^2.3.
|
|
66
|
+
"css-tree": "^2.3.1",
|
|
67
67
|
"string-hash": "^1.1.3"
|
|
68
68
|
}
|
|
69
69
|
}
|