ebullient/ttrpg-convert-cli

๐Ÿ› DnD 5e - not able to add item rarity into the frontmatter

Closed this issue ยท 4 comments

I am trying to add item rarity in the frontmatter, but I am not able to seem to pick up the information, and instead it throws an error.

I have tried several codes using resource.rarity or resource.detail.rarity, but I'm not able to extract that information

---
obsidianUIMode: preview
cssclasses: json5e-item
{#if resource.tags }
tags:
{#for tag in resource.tags}
- {tag}
{/for}
{/if}
aliases: 
- "{resource.name}"
{#if resource.variantAliases }
{resource.variantAliases}
{/if}
NoteIcon: ring
SourceType: Items
BookSource: ["{resource.source}"]
{#if resource.rarity }
Rarity: ["{resource.rarity}"]
{/if}
---

I would like the frontmatter output of the item to look like this:

---
obsidianUIMode: preview
cssclasses: json5e-item
tags:
- compendium/src/5e/dmg
- ttrpg-cli/item/rarity/uncommon
- ttrpg-cli/item/tier/minor
- ttrpg-cli/item/wondrous/wondrous-item
aliases: 
- "+1 Ammunition"
- "+1 Sling Bullet"
- "+1 Arrow"
- "+1 Modern Bullet"
- "+1 Blowgun Needle"
- "+1 Crossbow Bolt"
- "+1 Energy Cell"
- "+1 Renaissance Bullet"
NoteIcon: ring
SourceType: Items
BookSource: ["Dungeon Master's Guide p. 150. Available in the SRD."]
Rarity: ["uncommon"]
---

When I add the text as described above in the template file it results in the following errors for {resource.rarity}:
[ ๐Ÿ›‘ ERR] io.quarkus.qute.TemplateException: Rendering error: Property "rarity" not found on the base object "dev.ebullient.convert.tools.dnd5e.qute.QuteItem" in expression {resource.rarity}

and for `{resource.detail.rarity}
[ ๐Ÿ›‘ ERR] io.quarkus.qute.TemplateException: Rendering error: Property "rarity" not found on the base object "java.lang.String" in expression {resource.detail.rarity}

Configuration

  • OS: Linux (Ubuntu 22.04.4 LTS)
  • CLI version:
    ttrpg-convert version 2.3.8
    Git commit: bc7ce40
    Build time: 2024-04-18T16:40:43Z
  • CLI type: brew installation

Sources:

log file with run that included {resource.rarity}
ttrpg-convert.txt

detail is (currently) just a string, and item rarity/tier is only separately available as tags.

When an attribute has sub-attributes, I try to be clear about it in the docs, e.g.

sourceAndPage

Book sources as list of SourceAndPage

The latter SourceAndPage link shows the sub-attributes. I realize I was not clear in the detail description that it was a pre-formatted string containing those attributes.

Will think about how to capture those as sub-resources, they are not always present.

Thanks for the clarification! I would love to be able to add the rarity separately in the frontmatter to make it easier to parse with dataview

You can already parse with dataview, as tags are supported natively and you have those.

  • ttrpg-cli/item/rarity/uncommon
  • ttrpg-cli/item/tier/minor
  • ttrpg-cli/item/wondrous/wondrous-item

I guess I have to go back study on how to use that hehe! Thanks again! And wow you respond fast! Not used to that on github, much appreciated!