[TW5] Support with Tabs and transclusion

157 views
Skip to first unread message

TonyM

unread,
Jul 27, 2017, 6:01:48 AM7/27/17
to TiddlyWiki
Hi Folks,

Im stumped. Some help would be appreciated.

I have some tabs, generated using the content of a field !!objecttabs

<$set name=objecttablist value={{!!objecttabs}}>

@@.tabsstyle
<div>
<<tabs "$(objecttablist)$" "{{!!defaulttab}}" "" "" "subTiddlerView" >>
</div>
@@

</$set>

I am using the template parameter in tabs and this is my template "subTiddlerView"

!<<currentTiddler>> - <<currentTab>>

<$tiddler tiddler=<<currentTab>>>
<$transclude mode="block" />
</$tiddler>

<<subtiddlertab $(currentTab)$>>

Because of the way I generated the Tab list <<currentTab>> does not have the full name of the tiddlers I wish to transclude.
 "<<currentTiddler>> - <<currentTab>>" does display the name of the tiddlers I wish to Transclude.
The subsequent macro works with $(currentTab)$ = to the original items in the original tiddlers field.

Yet I have no idea how to pass "<<currentTiddler>> - <<currentTab>>" as the tiddler name into a transclusion? such that the tiddlers content apears in the tab.

Thanks in Advance
TonyM


Mark S.

unread,
Jul 27, 2017, 10:01:26 AM7/27/17
to TiddlyWiki
What you're trying to do is concatenate text and pass it to a transclusion. Almost always when you want to concatenate you need a macro. It might be something as simple as:

\define fulltitle() $(currentTiddler)$-$(currentTab)$

Good luck,
Mark

TonyM

unread,
Jul 27, 2017, 10:43:27 PM7/27/17
to TiddlyWiki
Mark s,

Thanks for the suggestion, its appreciated. I did go down that path, but I tried again, the template "subTiddlerView" now reads;

\define subtiddler()  <<currentTiddler>> - <<currentTab>>

<$tiddler tiddler=<<subtiddler>>>
<$transclude mode="block" />
</$tiddler>


<<subtiddlertab $(currentTab)$>>

Unfortunately this still does not work, both <<subtiddler>> and $(currentTab)$ give the required tiddler name when used/displayed and the latter macro <<subtiddlertab $(currentTab)$>> works as required, but nothing I seem to throw at the transclude seems to work. I have had it  working in another case where I use the tab filter  "[prefix[$(currentTiddler)$ - ]] +[sort[]]" to display the existing (only) subtiddlers tiddlers.

Mark S.

unread,
Jul 27, 2017, 11:44:43 PM7/27/17
to TiddlyWiki
I'm not sure why you reverted my example. Using macros within macros has proven unreliable to me, though I'm sure some of the gurus know exactly when it will work if they would ever explain it.

In any event, when I reverted to my example, and used (as the tabs template, but it worked just as well pasting into individual tabs), it seemed to work fine.

I've attached my sample. After importing, open TabVars and as you'll see the contents of the tiddler specified by the concatenated name gets transcluded.

Good luck!
Mark
tabvars-example.json

Eric Shulman

unread,
Jul 28, 2017, 12:04:35 AM7/28/17
to TiddlyWiki
On Thursday, July 27, 2017 at 7:43:27 PM UTC-7, TonyM wrote:
\define subtiddler()  <<currentTiddler>> - <<currentTab>>
 
On Friday, July 28, 2017 at 12:01:26 AM UTC+10, Mark S. wrote:
\define fulltitle() $(currentTiddler)$-$(currentTab)$


The difference between the first and second example is that the first syntax simply "returns" the macro content AS IS, with the expectation that further parsing will be performed to evaluate <<currentTiddler>> and <<currentTab>> values.  This is typically used if the macro output is to be *rendered* (displayed) directly as wiki content.

In contrast, the second syntax using $(...variablename...)$ actually evaluates the variable reference and substitutes the current values before "returning" the result to the calling syntax.  Thus, the second syntax does not depend upon any further parsing to get the actual values.  This is typically used when the macro output is to be used as a parameter value for another macro or widget 

Example:

Suppose that the currentTiddler value is "SomeTiddler" and the currentTab value is "SomeTab".

The output of the first macro is literally, "<<currentTiddler>> - <<currentTab>>", leaving any evaluation and replacement to be done later, while the output of the second macro is literally "SomeTiddler - SomeTab" (i.e., the macro processing does the evaluation and replacement immediately and the result is then used as the value of the parameter in the <$tiddler> widget.

I hope this makes sense.

enjoy,
-e
Eric Shulman
TiddlyTools.com: "Small Tools for Big Ideas" (tm)
InsideTiddlyWiki: The Missing Manuals

TonyM

unread,
Jul 29, 2017, 11:24:48 PM7/29/17
to TiddlyWiki
Mark,

I am not sure why I reverted your example as well, Thanks that works, arghh

TonyM

TonyM

unread,
Jul 29, 2017, 11:25:34 PM7/29/17
to TiddlyWiki
Eris,

It makes sense,

Thanks

Mark S.

unread,
Jul 29, 2017, 11:52:10 PM7/29/17
to TiddlyWiki
Thanks Eric. I had realized for some time that the first version never worked, but couldn't quite explain why.

Mark
Reply all
Reply to author
Forward
0 new messages