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

80 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: 20150117152625000
2014-10-02 15:02:48 +00:00
tags: WikiText
title: Variables in WikiText
type: text/vnd.tiddlywiki
2015-01-07 15:18:36 +00:00
\define tags() {{!!tags}}
2014-10-02 15:02:48 +00:00
2015-01-07 15:18:36 +00:00
[[Variables]] contain values. They are available within the scope of the [[widget|Widgets]] in which they are defined, as well as all child widgets in the widget tree.
2014-10-02 15:02:48 +00:00
2015-01-07 15:18:36 +00:00
!!Defining Variables
2014-10-02 15:02:48 +00:00
2015-01-07 15:18:36 +00:00
Variables are defined by...
2014-10-02 15:02:48 +00:00
2015-01-07 15:18:36 +00:00
; [[Macros|Macros in WikiText]]
: in fact, variables are macro shorthands (see example below)
; SetWidget
: sets a variable to a value
; ListWidget
: sets list-item and iterator variabes
; TiddlyWiki
: in the core and core templates
2014-10-02 15:02:48 +00:00
2015-01-07 15:18:36 +00:00
!!Using Variables
2014-10-02 15:02:48 +00:00
2015-01-11 19:09:35 +00:00
Variables are used...
2015-01-07 15:18:36 +00:00
2015-01-11 19:09:35 +00:00
; via shorthand
2015-01-07 15:18:36 +00:00
:`<<variableName>>`
2015-01-11 19:09:35 +00:00
; via variable substitution within [[macros|Macros]]
2015-01-07 15:18:36 +00:00
:`$(variableName)$`
2015-01-11 19:09:35 +00:00
; as parameters to [[filter steps|Filters]]
2015-01-07 15:18:36 +00:00
: `[operator<variableName>]`
; in [[widgets|Widgets]]
: internally, or as widget attributes
: `<$edit tiddler=<<currentTiddler>>/>`
!! Examples
''defining a variable via SetWidget''
```
<$set name=foo value=bar>
<<foo>>
</$set>
```
<<<
<$set name=foo value=bar>
<<foo>>
</$set>
<<<
''a variable is a macro''
Below, the `\define` pragma at the beginning of a tiddler [[defines the macro|Macros in WikiText]] `<<tags>>`, valid in the scope of the CurrentTiddler, returning the value of the standard `tags` field.
```
\define tags() {{!!tags}}
<<tags>>
```
<<<
<<tags>>
<<<
''using a filter variable to get all incoming links''
Using the <<olink backlinks>> [[filter operator|Filter Operators]] to get all tiddlers linking to this one...
2015-01-07 15:18:36 +00:00
```
<<list-links filter:"[<currentTiddler>backlinks[]]">>
```
<<<
<<list-links filter:"[<currentTiddler>backlinks[]]">>
<<<