On Sunday, August 11, 2013 10:47:16 AM UTC-7, Scott Simmons wrote:
>
> I have several tiddlers that transclude sections of their own content --
> mostly in tab sets like this:
>
> <<tabs txtMyTabs "first tab" "tab1" [[ThisTiddler##Tab 1's Contents]]
> "second tab" "tab2" [[This Tiddler##Tab2's Contents]]>>
>
> But when I rename ThisTiddler as (say) ThatTiddler, I have to replace all
> the instances of "ThisTiddler" in my tab set definition.
>
> Is there a way to reference the current tiddler (a la *this.tiddler*)
> that would work in this context? So that the tab set would continue to
> function fine despite the tiddler containing it (and the referenced
> sections) being renamed?
>
Try this (untested) code that "hijacks" the onClickTab() event handler to
add a little "fixup" code:
---------------------------------------------
// if the default TWCore function isn't saved yet, do it now.
if (!config.macros.tabs.orig_onClickTab)
config.macros.tabs.orig_onClickTab=config.macros.tabs.onClickTab;
// add fixup handling to correct for missing tiddler name in tab source
reference
config.macros.tabs.onClickTab = function(e)
{
// get the source reference for this tab
var content=this.getAttribute("content");
// if it starts with "##"
if (content.startsWith(config.textPrimitives.sectionSeparator) {
// get the name of the tiddler being viewed
var tid=story.findContainingTiddler(e).getAttribute("tiddler");
// add the tiddler name to the source reference for this tab
this.setAttribute("content",tid+content);
}
// allow the normal core tab handling to occur
return config.macros.tabs.orig_onClickTab.apply(this,arguments);
};
---------------------------------------------
Put the above code in a tiddler tagged with "systemConfig" (i.e., make it a
plugin) and the save-and-reload. To use, just write:
<<tabs txtMyTabs "first tab" "tab1" [[##Tab 1's Contents]] "second tab"
"tab2" [[##Tab2's Contents]]>>/%
!Tab 1's Contents
this is stuff in tab one
!Tab 2's Contents
this is stuff in tab two
!end
%/
enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"...
http://www.TiddlyTools.com/#Donations
Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:
http://www.TiddlyTools.com/#Contact
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/groups/opt_out.