Using sheet prepare on text template if available

This commit is contained in:
Vlyan
2021-10-03 20:04:28 +02:00
parent b5a21f950e
commit 2ca33fa104
5 changed files with 19 additions and 9 deletions

View File

@@ -217,7 +217,8 @@ export class ActorL5r5e extends Actor {
* @return {Promise<string|null>}
*/
async renderTextTemplate() {
const tpl = await renderTemplate(`${CONFIG.l5r5e.paths.templates}actors/actor-text.html`, this);
const data = (await this.sheet?.getData()) || this;
const tpl = await renderTemplate(`${CONFIG.l5r5e.paths.templates}actors/actor-text.html`, data);
if (!tpl) {
return null;
}

View File

@@ -134,9 +134,12 @@ export class ItemL5r5e extends Item {
* @return {Promise<string|null>}
*/
async renderTextTemplate() {
const data = (await this.sheet?.getData()) || this;
if (data instanceof ItemL5r5e) {
await game.l5r5e.HelpersL5r5e.refreshItemProperties(this);
}
const type = this.type.replace("_", "-"); // ex: item_pattern
await game.l5r5e.HelpersL5r5e.refreshItemProperties(this);
const tpl = await renderTemplate(`${CONFIG.l5r5e.paths.templates}items/${type}/${type}-text.html`, this);
const tpl = await renderTemplate(`${CONFIG.l5r5e.paths.templates}items/${type}/${type}-text.html`, data);
if (!tpl) {
return null;
}

View File

@@ -7,7 +7,8 @@ export class JournalL5r5e extends JournalEntry {
* @return {Promise<string|null>}
*/
async renderTextTemplate() {
const tpl = await renderTemplate(`${CONFIG.l5r5e.paths.templates}journal/journal-text.html`, this);
const data = (await this.sheet?.getData()) || this;
const tpl = await renderTemplate(`${CONFIG.l5r5e.paths.templates}journal/journal-text.html`, data);
if (!tpl) {
return null;
}