Files
fvtt-oath-hammer/module/utils.mjs
2026-03-08 17:27:59 +01:00

25 lines
803 B
JavaScript

export default class OathHammerUtils {
static registerHandlebarsHelpers() {
Handlebars.registerHelper("includes", (collection, value) => {
if (!collection) return false
if (collection instanceof Set) return collection.has(value)
if (Array.isArray(collection)) return collection.includes(value)
return false
})
Handlebars.registerHelper("capitalize", (str) => {
if (typeof str !== "string") return str
return str.charAt(0).toUpperCase() + str.slice(1)
})
Handlebars.registerHelper("concat", (...args) => {
args.pop() // remove handlebars options object
return args.join("")
})
}
static async loadCompendium(packId) {
const pack = game.packs.get(packId)
if (!pack) return []
return await pack.getDocuments()
}
}