boxwood 0.65.0 → 0.67.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 +16 -0
- package/package.json +3 -2
package/index.js
CHANGED
|
@@ -2,8 +2,13 @@ const { join } = require("path")
|
|
|
2
2
|
const { readFileSync } = require("fs")
|
|
3
3
|
const csstree = require("css-tree")
|
|
4
4
|
const toHash = require("string-hash")
|
|
5
|
+
const YAML = require("yaml")
|
|
5
6
|
|
|
6
7
|
async function compile(path) {
|
|
8
|
+
if (process.env.NODE_ENV === "development") {
|
|
9
|
+
const name = require.resolve(path)
|
|
10
|
+
delete require.cache[name]
|
|
11
|
+
}
|
|
7
12
|
const fn = require(path)
|
|
8
13
|
return {
|
|
9
14
|
template() {
|
|
@@ -458,6 +463,17 @@ function i18n(translations) {
|
|
|
458
463
|
}
|
|
459
464
|
}
|
|
460
465
|
|
|
466
|
+
i18n.load = function () {
|
|
467
|
+
const path = join(...arguments)
|
|
468
|
+
const content = readFileSync(path, "utf8")
|
|
469
|
+
const data = path.endsWith(".yaml")
|
|
470
|
+
? YAML.parse(content)
|
|
471
|
+
: JSON.parse(content)
|
|
472
|
+
return function translate(language, key) {
|
|
473
|
+
return data[key][language]
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
461
477
|
module.exports = {
|
|
462
478
|
compile,
|
|
463
479
|
classes,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "boxwood",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.67.0",
|
|
4
4
|
"description": "Compile HTML templates into JS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"css-tree": "^2.3.1",
|
|
67
|
-
"string-hash": "^1.1.3"
|
|
67
|
+
"string-hash": "^1.1.3",
|
|
68
|
+
"yaml": "^2.2.1"
|
|
68
69
|
}
|
|
69
70
|
}
|