Make it so that Handlebars partials get reloaded automatically

This commit is contained in:
Oliver-Akins 2023-11-26 01:30:15 -07:00
parent 93b55df045
commit dda38b6695
3 changed files with 45 additions and 11 deletions

View file

@ -1,3 +1,10 @@
export const partials = [
"actors/char-sheet-mvp/partials/dice_choice.hbs",
"actors/char-sheet-mvp/partials/stat.hbs",
"actors/char-sheet-mvp/partials/skill.hbs",
"actors/char-sheet-mvp/partials/panel.hbs",
]
export async function registerHandlebarsHelpers() {
Handlebars.registerHelper({
"dotdungeon-array": createArray
@ -7,20 +14,13 @@ export async function registerHandlebarsHelpers() {
export async function preloadHandlebarsTemplates() {
console.groupCollapsed(`.dungeon | Handlebars template loading`)
const pathPrefix = `systems/dotdungeon/templates/`;
const partials = [
"actors/char-sheet-mvp/partials/dice_choice.hbs",
"actors/char-sheet-mvp/partials/stat.hbs",
"actors/char-sheet-mvp/partials/skill.hbs",
"actors/char-sheet-mvp/partials/panel.hbs",
];
const paths = {};
for ( const partial of partials ) {
console.debug(`Loading partial: ${partial}`);
const path = `${pathPrefix}${partial}`;
paths[path] = path;
paths[`dotdungeon.${path.split("/").pop().replace(".hbs", "")}`] = path;
paths[`dotdungeon.${partial.split("/").pop().replace(".hbs", "")}`] = path;
}
console.debug(`Loaded ${partials.length} partials`);