diff --git a/core/modules/widgets/transclude.js b/core/modules/widgets/transclude.js index 1831f6b6d..b0a84a13a 100755 --- a/core/modules/widgets/transclude.js +++ b/core/modules/widgets/transclude.js @@ -279,6 +279,8 @@ TranscludeWidget.prototype.getTransclusionTarget = function() { defaultType: this.transcludeType }); } + // Set 'thisTiddler' + this.setVariable("thisTiddler",this.transcludeTitle); // Return the parse tree if(parser) { return { diff --git a/editions/test/tiddlers/tests/data/this-tiddler/Simple.tid b/editions/test/tiddlers/tests/data/this-tiddler/Simple.tid new file mode 100644 index 000000000..4aad83c98 --- /dev/null +++ b/editions/test/tiddlers/tests/data/this-tiddler/Simple.tid @@ -0,0 +1,29 @@ +title: ThisTiddler/Simple +description: Simple usage of thisTiddler variable +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Output + +\whitespace trim +\import Macro +\define print-this-tiddler() +<$text text=<>/> +\end + +(<$text text=<>/>) + +(<>) + +(<>) + ++ +title: Macro + +\define imported-print-this-tiddler() +<$text text=<>/> +\end ++ +title: ExpectedResult + +

(Output)

(Output)

(Output)

\ No newline at end of file diff --git a/editions/tw5.com/tiddlers/system/doc-macros.tid b/editions/tw5.com/tiddlers/system/doc-macros.tid index f1c99b748..e4a425f9a 100644 --- a/editions/tw5.com/tiddlers/system/doc-macros.tid +++ b/editions/tw5.com/tiddlers/system/doc-macros.tid @@ -134,7 +134,11 @@ This is an example tiddler. See [[Table-of-Contents Macros (Examples)]].
<$reveal default="$egvar$" type="match" text="NO-SUCH-VAR"> - $eg$ + +$$$text/vnd.tiddlywiki +$eg$ +$$$ + <$reveal default="$egvar$" type="nomatch" text="NO-SUCH-VAR"> <<$egvar$>> diff --git a/editions/tw5.com/tiddlers/thisTiddler Variable (Examples).tid b/editions/tw5.com/tiddlers/thisTiddler Variable (Examples).tid new file mode 100644 index 000000000..d0adc6167 --- /dev/null +++ b/editions/tw5.com/tiddlers/thisTiddler Variable (Examples).tid @@ -0,0 +1,13 @@ +created: 20230304123606350 +modified: 20230304124149055 +tags: [[currentTiddler Variable]] [[Variable Examples]] +title: thisTiddler Variable (Examples) +type: text/vnd.tiddlywiki + + + +<$macrocall $name=".example" n="1" eg="""<$text text=<>/>"""/> + +<$macrocall $name=".example" n="2" eg="""\define example() <$text text=<>/> +<> +"""/> diff --git a/editions/tw5.com/tiddlers/thisTiddler Variable.tid b/editions/tw5.com/tiddlers/thisTiddler Variable.tid new file mode 100644 index 000000000..95b6b901c --- /dev/null +++ b/editions/tw5.com/tiddlers/thisTiddler Variable.tid @@ -0,0 +1,12 @@ +caption: currentTiddler +created: 20230304122810114 +modified: 20230304123557862 +tags: Variables [[Core Variables]] +title: thisTiddler Variable +type: text/vnd.tiddlywiki + +<<.from-version "5.3.0">> The <<.def thisTiddler>> [[variable|Variables]] is set by the <<.wlink TranscludeWidget>> widget to contain the title of the tiddler that was transcluded. This means that within a tiddler <<.def thisTiddler>> will contain the title of that tiddler. It is not affected by macros, which means that within a macro <<.def thisTiddler>> will contain the title of the tiddler from which the macro was invoked. Intermediate, nested macro calls are ignored. + +Compare <<.vlink storyTiddler>> and <<.vlink currentTiddler>>. + +<<.variable-examples "thisTiddler">>