1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-27 10:30:28 +00:00
TiddlyWiki5/editions/tw5.com/tiddlers/wikitext/Variables in WikiText.tid

37 lines
1.7 KiB
Plaintext
Raw Normal View History

2014-10-02 23:15:06 +00:00
caption: Variables
2014-10-02 15:02:48 +00:00
created: 20141002141231992
modified: 20150221221850000
2014-10-02 15:02:48 +00:00
tags: WikiText
title: Variables in WikiText
type: text/vnd.tiddlywiki
See also the [[introduction to the concept of variables|Variables]].
2014-10-02 15:02:48 +00:00
To transclude the value of a variable, use the [[macro call syntax|Macro Calls in WikiText]] with no parameters. You can also use a <<.wlink MacroCallWidget>> widget.
2014-10-02 15:02:48 +00:00
A [[macro|Macros]] snippet can contain `$(name)$` as a [[placeholder|Macro Definitions in WikiText]] for which the value of the variable of that name will be substituted.
2014-10-02 15:02:48 +00:00
A variable's value can be used as a [[filter parameter|Filter Parameter]], or as a [[widget attribute|Widgets in WikiText]]. The latter supports macro parameters.
2014-10-02 15:02:48 +00:00
!! Example: defining a variable
2014-10-02 15:02:48 +00:00
<$macrocall $name=".example" n="1"
eg="""<$set name=animal value=zebra>
<<animal>>
</$set>"""/>
2014-10-02 15:02:48 +00:00
!! Example: defining a macro
2015-01-07 15:18:36 +00:00
The `\define` pragma below [[defines a macro|Macros in WikiText]] called <<.var tags-of-current-tiddler>>. The macro returns the value of the tiddler's <<.field tags>> field, and can be accessed from anywhere else in the same tiddler (or in any tiddler that [[imports|ImportVariablesWidget]] it).
2015-01-07 15:18:36 +00:00
<$importvariables filter="$:/editions/tw5.com/macro-examples/tags-of-current-tiddler">
<$codeblock code={{$:/editions/tw5.com/macro-examples/tags-of-current-tiddler}}/>
<$macrocall $name=".example" n="2" eg="""The tags are: <<tags-of-current-tiddler>>"""/>
</$importvariables>
2015-01-07 15:18:36 +00:00
!! Example: using a variable as a filter parameter
2015-01-07 15:18:36 +00:00
This example uses the <<.olink backlinks>> [[operator|Filter Operators]] to list all tiddlers that link to this one.
2015-01-07 15:18:36 +00:00
<$macrocall $name=".example" n="3" eg="""<<list-links filter:"[<currentTiddler>backlinks[]]">>"""/>