bajo-template 2.5.2 → 2.5.3
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 +8 -11
- package/package.json +1 -1
- package/wiki/CHANGES.md +7 -3
package/index.js
CHANGED
|
@@ -239,23 +239,20 @@ async function factory (pkgName) {
|
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
compile = async (content, locals, { lang, ttl = 0 } = {}) => {
|
|
242
|
-
|
|
242
|
+
const { get: getCache, set: setCache } = this.app.bajoCache ?? {}
|
|
243
243
|
const { template } = this.app.lib._
|
|
244
|
-
|
|
245
|
-
let canCache = this.config.cache !== false && cache && this.app.bajo.config.env !== 'dev'
|
|
246
|
-
if (ttl === -1) canCache = false
|
|
244
|
+
locals.attr = locals.attr ?? {}
|
|
247
245
|
const opts = {
|
|
248
246
|
imports: this.buildCompileImports(lang)
|
|
249
247
|
}
|
|
250
|
-
|
|
248
|
+
const key = 'fn:' + crypto.createHash('md5').update(content).digest('hex')
|
|
251
249
|
let item
|
|
252
|
-
if (
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
item = await cache.sync({ key, value, ttl })
|
|
256
|
-
} else {
|
|
257
|
-
item = template(content, opts)
|
|
250
|
+
if (getCache) {
|
|
251
|
+
item = await getCache({ key })
|
|
252
|
+
if (item) return item(locals)
|
|
258
253
|
}
|
|
254
|
+
item = template(content, opts)
|
|
255
|
+
if (setCache) await setCache({ key, value: item, ttl })
|
|
259
256
|
return item(locals)
|
|
260
257
|
}
|
|
261
258
|
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-03-25
|
|
4
|
+
|
|
5
|
+
- [2.5.3] Bug fix in cache handling for template function
|
|
6
|
+
|
|
3
7
|
## 2026-03-14
|
|
4
8
|
|
|
5
|
-
- [2.5.2] Bug fix
|
|
9
|
+
- [2.5.2] Bug fix in ```resolveResource()```
|
|
6
10
|
|
|
7
11
|
## 2026-02-21
|
|
8
12
|
|
|
9
|
-
- [2.5.1] Bug fix
|
|
13
|
+
- [2.5.1] Bug fix in layout fallback
|
|
10
14
|
- [2.5.1] Refactoring ```resolveResource()``` to be more modular
|
|
11
15
|
|
|
12
16
|
## 2026-02-17
|
|
@@ -24,7 +28,7 @@
|
|
|
24
28
|
|
|
25
29
|
## 2026-02-05
|
|
26
30
|
|
|
27
|
-
- [2.2.2] Bug fix
|
|
31
|
+
- [2.2.2] Bug fix in front matter parsing
|
|
28
32
|
|
|
29
33
|
## 2026-01-21
|
|
30
34
|
|