TiddlerFrodo! Description
Frodo Baggins is a Hobbit who lives in a hole in the ground.
! Stats
Name: Frodo Baggins
Home: Hobbiton
Occupation: Ring-BearerTiddlerSamwise! Description
Samwise Gamgee is a Hobbit who is in love Rosie.
! Stats
Name: Samwise Gamgee
Home: Hobbiton
Occupation: GardnerThe solution I've been trying, but have been coming up short with, is to have what I'm calling a "template" tiddler (but I'm not sure if that's what it really is TW) that contains the repetitive parts of the text above. I'm defining a macro and using variables for the changing parts.
TiddlerTemplate
\define character(description, name, home, occupation)
! Description
$description$
! Stats
Name: $name$
Home: $home$
Occupation: $occupation$
\endNext, I have a json data tiddler (I'm not sure if JSON or the dictionary tiddler is better) that looks like:
TiddlerData[
{
"Description":"Frodo Baggins is a Hobbit who lives in a hole in the ground.",
"Name": "Frodo Baggins",
"Home": "Hobbiton",
"Occupation": "Ring-Bearer"
},
{
"Description":"Samwise Gamgee is a Hobbit who is in love Rosie.",
"Name": "Samwise Gamgee",
"Home": "Hobbiton",
"Occupation": "Gardner"
}
]!Name: {{!!name}}
!! Description
{{!!description}}
!! Stats
Name: {{!!name}}
Home: {{!!home}}
Occupation: {{!!occupation}}\define DisplayCharacter(Character)
{{$:/data/Characters/$Character$||OMGACHARACTER}}
\end
\define DisplayCharacterStat(Character, Stat)
<$view tiddler="""$:/data/Characters/$Character$""" field=$Stat$/>
\end
To display a chracatres stat block use the `DisplayCharacter` macro
Usage: `<<DisplayCharacter "Samwise Gamgee">>`
Result:
<<DisplayCharacter "Samwise Gamgee">>
To display a specific stat for a character use the `DisplayCharacterStat` macro
Usage: `<<DisplayCharacterStat "Samwise Gamgee" "home">>`
<<DisplayCharacterStat "Samwise Gamgee" "home">>
!! Stats
Name: {{!!title}}
Home: {{!!role-home}}
Occupation: {{!!role-occupation}}