1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-15 04:30:27 +00:00
TiddlyWiki5/editions/tw5.com/tiddlers/wikitext/Transclusion and Substitution.tid
Mario Pietsch 1001590326
Macros -- Make "New in 5.3.0" Info More Prominent (#7750)
* Macros -- Make "New in 5.3.0" Info More Prominent

* Add links to new text substitution possibilities
2023-10-30 14:51:06 +00:00

61 lines
2.1 KiB
Plaintext

created: 20141018090608643
modified: 20231030124224424
tags: WikiText
title: Transclusion and Substitution
type: text/vnd.tiddlywiki
The power of WikiText comes from the ability to use the content of one tiddler inside another one. This ability takes several different forms that can easily be confused.
The main distinction is between a transclusion and a textual substitution:
* A transclusion is replaced dynamically with the value of either:
** a tiddler field
** a variable
* Textual substitutions are performed on the text of macro definitions before they are used
! Tiddler Field Transclusion
[[Transclusion in WikiText]] describes the basics of transclusion. For example:
```
{{MyTiddler}}
```
As described in [[HTML in WikiText]], you can also transclude tiddler field values as attributes of HTML elements and widgets. For example:
```
<$text text={{MyTiddler}}/>
```
As described in [[Introduction to filter notation]], you can also transclude tiddler field values as filter operands. For example:
```
{{{ [tag{TiddlerContainingMyTag}] }}}
```
! Variable/Macro Transclusion
Variables that were defined with parameter or variable substitution are referred to as "macros". The value of a variable/macro can be transcluded with the syntax:
```
<<myMacro param:"Value of parameter">>
```
As described in [[HTML in WikiText]], you can also transclude a variable as the value of an attribute of HTML elements and widgets. For example:
```
<$text text=<<myMacro>>/>
```
As described in [[Introduction to filter notation]], you can also transclude a variable as the value of a filter operand. For example:
```
{{{ [tag<myMacro>] }}}
```
! Textual Substitution
Textual substitution occurs when the value of a macro/variable is used. It is described in [[Substituted Attribute Values]] and [[substitute Operator]]
The key difference between substitution and transclusion is that substitution occurs before WikiText parsing. This means that you can use substitution to build ~WikiText constructions. Transclusions are processed independently, and cannot be combined with adjacent text to define ~WikiText constructions.