For the last 24 hours, I've been trying various methods to solve the 
following problem.  I want to have multiple tiddlers that have a similar 
format but with some variation (which I'll show below).  I've looked into 
templates, transclusion, DataTiddlers, and macros, and I haven't yet been 
able to put all the pieces together to achieve my goal.  I'm still very new 
to TiddlyWiki.  Here's a simple version of what I'm trying to achieve:

*TiddlerFrodo*
! Description
Frodo Baggins is a Hobbit who lives in a hole in the ground.

! Stats
Name: Frodo Baggins
Home: Hobbiton
Occupation: Ring-Bearer

*TiddlerSamwise*
! Description
Samwise Gamgee is a Hobbit who is in love Rosie.

! Stats

Name: Samwise Gamgee
Home: Hobbiton
Occupation: Gardner


The 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.


*Tiddler**Template*

\define character(description, name, home, occupation)
! Description
$description$

! Stats
Name: $name$
Home: $home$
Occupation: $occupation$
\end

Next, 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"
  }
]

Finally, in TiddlerFrodo and TiddlerSamwise, I'm calling the character 
macro I defined, but I'm not sure how to get at the corresponding data in 
the data tiddler.  When it's just one set of data, I know I can get at it 
with something like {{TiddlerData##Description}}, but when I have multiple 
sets of data, I'm at a loss.  So, my questions are:

1. What's the best way to achieve my initial goal?
2. If what I'm doing is essentially fine, what's the syntax for grabbing 
the JSON data?

Thanks,
Jeff

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/2003bcac-482e-44e6-8024-186c2fe0afb9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to