From 46e6fb195779fbbc0d3354d448d1196fb5f6fb7c Mon Sep 17 00:00:00 2001 From: Erwan Moreau Date: Tue, 9 Dec 2014 14:44:28 +0000 Subject: [PATCH] Create TransclusionBasicUsage.tid --- .../concepts/TransclusionBasicUsage.tid | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 editions/tw5.com/tiddlers/concepts/TransclusionBasicUsage.tid diff --git a/editions/tw5.com/tiddlers/concepts/TransclusionBasicUsage.tid b/editions/tw5.com/tiddlers/concepts/TransclusionBasicUsage.tid new file mode 100644 index 000000000..06402d365 --- /dev/null +++ b/editions/tw5.com/tiddlers/concepts/TransclusionBasicUsage.tid @@ -0,0 +1,44 @@ +created: 20141129201509859 +creator: Erwan +modified: 20141130194810119 +modifier: Erwan +tags: Transclusion +title: TransclusionBasicUsage + +! Simple transclusion + +To include some content from ~TiddlerA into ~TiddlerB, edit the latter and write: + +``` +This is the content of TiddlerA: {{TiddlerA}} +``` + + + As a result, the content of the field ``text`` (i.e. the main content) of ~TiddlerA is rendered in ~TiddlerB. + +! Usage + + +The notation ``{{TiddlerA}}`` is actually a shortcut for ``{{TiddlerA!!text}}``. This is because by default the transcluded field is ``text``, but any other [[field|TiddlerFields]] can be used explicitly. For example, you can print the last time ~TiddlerA was modified using: + +``` +TiddlerA was modified on {{TiddlerA!!modified}} +``` + +The ``{{...!!...}}`` notation is also used to display the content of a field from the current tiddler, for example: + +``` +The current tiddler was modified on {{!!modified}} +``` + +This is because displaying a field is also a form of transclusion. In this case, the notation ``{{!!modified}}`` used in ~TiddlerB is equivalent to ``{{TiddlerB!!modified}}``. In other words, the default value for the part before ``!!`` is the title of the current tiddler. + +! Recursion errors + +Notice that using ``{{!!text}}`` or ``{{}}`` causes an error (//Recursive transclusion error in transclude widget//), because it does not make sense to include the content of the current tiddler into the content of the current tiddler (that is, into itself). Whenever you encouter this error message, it means that you are trying to include something into itself, directly or not (for example if tiddler A transcludes tiddler B which transcludes tiddler C which, in turn, transcludes tiddler A). + +! Going further + +In TiddlyWiki, transclusions are not limited to including raw content like the above. To learn about a more advanced kind of transclusion, see TransclusionAsTemplateUsage. + +See also: TransclusionAsTemplateUsage, [[Transclusion in WikiText]], TextReference, and TiddlerFields.