Retrieving from a data dictionary, different results for transcluding using alphanumeric

89 views
Skip to first unread message

Shareen

unread,
Mar 1, 2019, 5:20:03 PM3/1/19
to TiddlyWiki
I am using data dictionaries to generate details for randomly generated stuff (in this case towns) for tabletop gaming. 
I found that using either alpha or numeric calls work for dictionaries filled with a mix of alpha and numeric: {{Datadictionary Name##AlphaOrNumericIndex}}, yay!
However, the $transclude calls do not work for both alpha and numeric, just numeric.
Does anyone know if I am calling this correctly?

TW5 version: 5.1.17


Data Dictionary
Returns numerically indexed values depending on which alphanumeric it is sent:
type: application/x-tiddler-dictionary

name: Available List
Hamlet: <$wikify name=randy text=<<RollDice  num_dice: '1'  dice_size: '2' dice_add:'0'>> ><$transclude $name="Available List" index=<<randy>>/></$wikify>
Village: <$wikify name=randy text=<<RollDice  num_dice: '1'  dice_size: '3' dice_add:'0'>> ><$transclude $name="Available List" index=<<randy>>/></$wikify>
1: CCC
2: DDD
3: EEE

Trials

  1. {{Available List##Hamlet}}: Returns CCC or DDD as expected
  2. {{Available List##1}}: Returns CCC as expected
  3. <$transclude tiddler="Available List" index=1/> : Returns CCC as expected
  4. <$transclude tiddler="Available List" index="Hamlet"/>: Nothing returns, expect one of 4 or 5 to act like #1
  5. <$transclude tiddler="Available List" index=Hamlet/>: Nothing returns
  6. <$transclude tiddler="Available List" index=$(A)$/> & <$transclude tiddler="Available List" index=$A$/>: Nothing return, did not expect them to.

Longer explanation on why I am using transclude:

Each data dictionary has 1 to n  values, often a hundred or more. 
In a "generator" tiddler I define the size of a town, and it is used repeatedly in the tiddler to grab details. 
Often there is a great deal of overlap, and instead of making a ton of lists, one of each list for every flavor of town size, I used shared lists and roll on them appropriately.

\define TownSize() Hamlet


Detail 1: <$transclude tiddler="X Available" index=<<TownSize>> />
Detail 2: <$transclude tiddler="Y Available" index=<<TownSize>> />
Detail 3: <$transclude tiddler="Available List" index=<<TownSize>> />


Joshua Fontany

unread,
Mar 1, 2019, 5:37:12 PM3/1/19
to TiddlyWiki
Neat use-case! I will have to poke at this. My JsonMangler plugin is also intended for use in a tabletop gaming wiki, but I have not played around with the other style Data Tiddler.

But what you are most likely running into is that {{this}} is a shortcut for a pair of nested widgets:
<$tiddler tiddler="this" ><$transclude tiddler="this" /></$tiddler>

Which sets the <<currentTiddler>> variable to "this", and _then_ transcludes the contents of "this" into that context.

Not sure on just scanning why this would break your translcusion, but try:

<$tiddler tiddler="Available List"><$transclude tiddler="Available List" index="Hamlet"/></$tiddler>

See if there is any different behavior.

Best,
Joshua Fontany

Shareen

unread,
Mar 1, 2019, 6:03:43 PM3/1/19
to TiddlyWiki
Thanks!

I gave it a try...

<$tiddler tiddler="Available List"><$transclude tiddler="Available List" index="Hamlet"/></$tiddler> returns nothing =(

Joshua Fontany

unread,
Mar 1, 2019, 6:23:11 PM3/1/19
to TiddlyWiki
Hmmm, this is odd. I tried on Tiddlywiki.com (5.1.19) by recreating your data-tiddler, and then trying some basic transclude tests. Here are the results.

{{Available List##Hamlet}}
{{Available List##Village}}

These both transcluded the FULL text of the tiddler(?!?), while non-existent indexes returned nothing, and numeric indexes returned their correct value.

<$transclude tiddler="Available List" index="Hamlet"/>

This returned Recursive transclusion error in transclude widget

Hmm, this may have to do with both numeric and non-numeric indexes in the same tiddler and how the wiki manages data-tiddlers internally.

Have you tried with a JSON tiddler?

Best,
Joshua F

Joshua Fontany

unread,
Mar 1, 2019, 6:33:44 PM3/1/19
to TiddlyWiki
More testing. Its definitely the $wikify widget causing this weird behaviour. I changed the Village data to:
<$transclude $name='Available List' index='1'/>
And it worked fine. Still poking around.

Are the contents of Data Tiddlers wikified before they are accessed? That would be odd...

Best,
Joshua F

Shareen

unread,
Mar 1, 2019, 6:40:06 PM3/1/19
to TiddlyWiki
Hmm, I wonder if there were changes between 17 (which is what I am using) and 19.
That both {{Available List##Hamlet}} and {{Available List##Village}} returned the full text is.. odd... 
The JSON tiddler did not seem to return anything when Ihad both alpha and numeric...

This did work, once I realized as I added a space somehow between when I copied  it here and into my test tiddler. =D Spaces matter. When in doubt, rip it out.. and try again.
<$tiddler tiddler="Available List"><$transclude tiddler="Available List" index="Hamlet"/></$tiddler>

Eric Shulman

unread,
Mar 1, 2019, 7:57:36 PM3/1/19
to TiddlyWiki
On Friday, March 1, 2019 at 2:20:03 PM UTC-8, Shareen wrote:
Does anyone know if I am calling this correctly?
...
Hamlet: <$wikify name=randy text=<<RollDice  num_dice: '1'  dice_size: '2' dice_add:'0'>> ><$transclude $name="Available List" index=<<randy>>/></$wikify>

You've used the wrong parameter name in the $transclude widget!
It's supposed to be "tiddler" ... not "$name"... like this:

Hamlet: <$wikify name=randy text=<<RollDice  num_dice: '1'  dice_size: '2' dice_add:'0'>> ><$transclude tiddler="Available List" index=<<randy>>/></$wikify>

Without the correct parameter name, the transclusion looks for the index in *the current tiddler* rather than "AvailableList".  The reason that {{AvailableList##Hamlet}} worked is because the {{...}} syntax implictly sets the currentTiddler to "AvailableList", so that the default use of currentTiddler within the retrieved index value will still get the desired result.

That should fix it.  Let me know how it goes.

-e


Joshua Fontany

unread,
Mar 2, 2019, 12:41:57 PM3/2/19
to TiddlyWiki
Great catch. Syntax gremlins still get me all the time.
Reply all
Reply to author
Forward
0 new messages