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

79 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
2015-01-07 15:18:36 +00:00
modified: 20150107121000000
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-07 15:18:36 +00:00
Variables are used via...
; shorthand
:`<<variableName>>`
; variable substitution within [[macros|Macros]]
:`$(variableName)$`
; as variable operands in [[filter expressions|Introduction to Filters]]
: `[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 [[backlinks|FilterOperator: backlinks]] [[filter operator|FilterOperators]] to get all tiddlers linking to this one...
```
<<list-links filter:"[<currentTiddler>backlinks[]]">>
```
<<<
<<list-links filter:"[<currentTiddler>backlinks[]]">>
<<<