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 CHANGED
@@ -239,23 +239,20 @@ async function factory (pkgName) {
239
239
  }
240
240
 
241
241
  compile = async (content, locals, { lang, ttl = 0 } = {}) => {
242
- locals.attr = locals.attr ?? {}
242
+ const { get: getCache, set: setCache } = this.app.bajoCache ?? {}
243
243
  const { template } = this.app.lib._
244
- const cache = this.app.bajoCache
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 (canCache) {
253
- const key = 'fn:' + crypto.createHash('md5').update(content).digest('hex')
254
- const value = template(content, opts)
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bajo-template",
3
- "version": "2.5.2",
3
+ "version": "2.5.3",
4
4
  "description": "Template Renderer for Bajo Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
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 on ```resolveResource()```
9
+ - [2.5.2] Bug fix in ```resolveResource()```
6
10
 
7
11
  ## 2026-02-21
8
12
 
9
- - [2.5.1] Bug fix on layout fallback
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 on front matter parsing
31
+ - [2.2.2] Bug fix in front matter parsing
28
32
 
29
33
  ## 2026-01-21
30
34