1
0
mirror of https://git.sr.ht/~cadence/bibliogram synced 2024-09-21 04:57:29 +00:00
bibliogram/html/static/js/templates/templates.js

15 lines
375 B
JavaScript
Raw Normal View History

2020-01-12 12:50:21 +00:00
import {AsyncValueCache} from "../avc/avc.js"
const tc = new AsyncValueCache(true, () => {
return fetch("/api/templates").then(res => res.json()).then(data => {
Object.keys(data).forEach(key => {
let fn = Function(data[key] + "; return template")()
data[key] = fn
})
console.log(`Loaded ${Object.keys(data).length} templates`)
return data
})
})
export {tc}