currentTiddler and tabs macro

221 views
Skip to first unread message

Mohammad

unread,
Oct 6, 2019, 9:05:25 AM10/6/19
to TiddlyWiki
When you use a tiddler with tabs macro Tiddlywiki refers to currentTiddler to the last tiddler in which rendering is occurred!

This make macros with currentTiddler as input parameter break and work wrongly!

Isn't it better to remove this from tabs macro?

Example
see this macro

\define code-link(tiddler)
<$set name=selected-tiddler value="$tiddler$" emptyValue=<<currentTiddler>> >
<$link to=<<selected-tiddler>>/>
<$codeblock language={{{[<selected-tiddler>get[type]]}}} code={{{[<selected-tiddler>get[text]]}}}/
>
</$set>
\end




Use it inside a tiddler say myTiddler tagged demo with no input parameter!

Now in another tiddler put the below script

<<tabs tabsList:"[tag[demo]]" class:"tc-vertical">>

You will see wrong result!


--Mohammad

Jeremy Ruston

unread,
Oct 6, 2019, 9:26:46 AM10/6/19
to tiddl...@googlegroups.com
Hi Mohammad

I’m afraid I'm not quite following. The tabs macro intentionally doesn’t affect the current tiddler.

Best wishes

Jeremy

--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/231b0bef-7553-4a5b-9a58-5d3c08e6b2b4%40googlegroups.com.

Mohammad

unread,
Oct 6, 2019, 12:22:18 PM10/6/19
to TiddlyWiki
Hi Jeremy,
Sorry for my bad English composition!

I have created an example



look at what tiddler Test01 displays when it is opened by itself and when it is opened inside tabs!

Here Test01 calls a user defined macro (code-link) to show the raw text (code) of a tiddler.

The macro code-link uses the variable currentTiddler.

This currentTiddler shows different results in different situation.

I have used red color to highlight the difference.

--Mohammad



On Sunday, October 6, 2019 at 4:56:46 PM UTC+3:30, Jeremy Ruston wrote:
Hi Mohammad

I’m afraid I'm not quite following. The tabs macro intentionally doesn’t affect the current tiddler.

Best wishes

Jeremy

When you use a tiddler with tabs macro Tiddlywiki refers to currentTiddler to the last tiddler in which rendering is occurred!

This make macros with currentTiddler as input parameter break and work wrongly!

Isn't it better to remove this from tabs macro?

Example
see this macro

\define code-link(tiddler)
<$set name=selected-tiddler value="$tiddler$" emptyValue=<<currentTiddler>> >
<$link to=<<selected-tiddler>>/>
<$codeblock language={{{[<selected-tiddler>get[type]]}}} code={{{[<selected-tiddler>get[text]]}}}/
>
</$set>
\end




Use it inside a tiddler say myTiddler tagged demo with no input parameter!

Now in another tiddler put the below script

<<tabs tabsList:"[tag[demo]]" class:"tc-vertical">>

You will see wrong result!


--Mohammad

--
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 tiddl...@googlegroups.com.

Jeremy Ruston

unread,
Oct 6, 2019, 12:38:56 PM10/6/19
to tiddl...@googlegroups.com
Hi Mohammad

The reason the content of Test01 displays differently in the tiddler “Tabs Macro Example” is because the current tiddler is “Tabs Macro Example”, which is inherited by the transcluded content of Test01. When displaying Test01 on its own the current tiddler will be “Test01”.

In other words, the tabs macro is a red herring. If you copy and paste the content of Test01 directly into “Tabs Macro Example” you’ll see the same output.

Best wishes

Jeremy.

To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/72ca2338-266e-4cb8-84fd-94875c34eeaa%40googlegroups.com.

Mohammad

unread,
Oct 6, 2019, 1:38:45 PM10/6/19
to TiddlyWiki
Hi Jeremy!

Thanks for clarification!
I understood transclusion is inheritable.

--Mohammad


On Sunday, October 6, 2019 at 8:08:56 PM UTC+3:30, Jeremy Ruston wrote:
Hi Mohammad

The reason the content of Test01 displays differently in the tiddler “Tabs Macro Example” is because the current tiddler is “Tabs Macro Example”, which is inherited by the transcluded content of Test01. When displaying Test01 on its own the current tiddler will be “Test01”.

In other words, the tabs macro is a red herring. If you copy and paste the content of Test01 directly into “Tabs Macro Example” you’ll see the same output.

Best wishes

Jeremy.

Eric Shulman

unread,
Oct 6, 2019, 5:16:09 PM10/6/19
to TiddlyWiki
On Sunday, October 6, 2019 at 10:38:45 AM UTC-7, Mohammad wrote:
I understood transclusion is inheritable.
On Sunday, October 6, 2019 at 8:08:56 PM UTC+3:30, Jeremy Ruston wrote:
The reason the content of Test01 displays differently in the tiddler “Tabs Macro Example” is because the current tiddler is “Tabs Macro Example”, which is inherited by the transcluded content of Test01. When displaying Test01 on its own the current tiddler will be “Test01”.

A bit more clarification:

When displaying tabs, the value of <<currentTiddler>> is dependent upon the tiddler in which the tabset is rendered.  This allows you to use tabs to show information related to that containing tiddler (e.g., the "info" tabset displayed from the "more" menu for each tiddler shows information about the tiddler containing that tabset).  However, for some use-cases, the intention of the tabset is to simply show a set of tiddlers, where the content of each tiddler is independent of the tabset in which they are shown.

Fortunately, there IS a way to achieve this, by using the <<currentTab>> variable within the specific tab content, like this:

<$tiddler tiddler=<<currentTab>>
... normal tiddler content here ...
</$tiddler>

When the above code is displayed directly (i.e., NOT within a tab), then <<currentTab>> has *no value*, so the <$tiddler> widget does nothing, and you get content using that tiddler's fields as the source.

When the tiddler is displayed from within a tab, then the <<currentTab>> value is the title of the source tiddler for that tab so you still get content using that tiddler's field as the source.

hope this helps,

enjoy,
-e







Mohammad

unread,
Oct 6, 2019, 5:23:24 PM10/6/19
to TiddlyWiki
Thank you Eric!

That's did the trick for me to keep my macro with default value of input parameter as currentTiddler!

Cheers
Mohammad

TonyM

unread,
Oct 6, 2019, 6:57:54 PM10/6/19
to TiddlyWiki
Mohamad et al

I nice little extencion to this is once the current tiddler is set, such as inside the tiddler widget you can immediately make use of other items such as buttons that operate on the current tiddler. One example is the edit button;

<$tiddler tiddler=<<currentTab>>

... normal tiddler content here ...
{{||$:/core/ui/Buttons/edit}}
</$tiddler>

Note the "||" to make it a template applied to the currentTiddler.

You will now have an edit tab tiddler button. This can be placed inside the "tab template tiddler" or the "individual tabs tiddler". But you could use this to provide clone, open in new window buttons etc...

This highlights one of my strongest Tiddlywiki design principles, build macros and solutions that "act on currentTiddler" wherever possible, even if you provide an override parameter to pass another tiddler name.

Regards
Tony

Mohammad

unread,
Oct 7, 2019, 5:17:02 AM10/7/19
to TiddlyWiki
Love it!
Reply all
Reply to author
Forward
0 new messages