mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10:07:19 +00:00
Merge pull request #992 from Eucaly/variables
add Subsitutions in WikiText
This commit is contained in:
commit
3305874235
@ -1,6 +1,6 @@
|
|||||||
caption: Variables
|
caption: Variables
|
||||||
created: 20141002141231992
|
created: 20141002141231992
|
||||||
modified: 20141002230751664
|
modified: 20141018104313995
|
||||||
tags: WikiText
|
tags: WikiText
|
||||||
title: Variables in WikiText
|
title: Variables in WikiText
|
||||||
type: text/vnd.tiddlywiki
|
type: text/vnd.tiddlywiki
|
||||||
@ -25,4 +25,4 @@ Variables are used in:
|
|||||||
* [[Filter expression|Introduction to Filters]] `[operator<variable-operand>]`
|
* [[Filter expression|Introduction to Filters]] `[operator<variable-operand>]`
|
||||||
* Some default behaviors of [[Widgets]]
|
* Some default behaviors of [[Widgets]]
|
||||||
|
|
||||||
See also [[currentTiddler|WidgetVariable: currentTiddler]] variable and built-in [[variables|Variables]].
|
See also [[currentTiddler|WidgetVariable: currentTiddler]] variable, built-in [[variables|Variables]] and [[subsitutions in WikiText|Variables, Macros and Subsitutions in WikiText]]
|
@ -0,0 +1,53 @@
|
|||||||
|
caption: Variables, Parameters, Subsitutions
|
||||||
|
created: 20141018090608643
|
||||||
|
modified: 20141018104201050
|
||||||
|
tags: WikiText
|
||||||
|
title: Variables, Macros and Subsitutions in WikiText
|
||||||
|
type: text/vnd.tiddlywiki
|
||||||
|
|
||||||
|
! Syntax for Attributes
|
||||||
|
|
||||||
|
The syntax for the attributes of [[HTML elements|HTML in WikiText]] and [[widgets|Widgets in WikiText]]:
|
||||||
|
|
||||||
|
* `"text"` or `'text'` - passed as a literal value
|
||||||
|
* `{{text reference}}` - [[transcludes|Transclusion in WikiText]] a text reference
|
||||||
|
* `<<macro>>` - transcludes a variable or macro invocation.
|
||||||
|
|
||||||
|
! Syntax for Filter
|
||||||
|
|
||||||
|
Using single brace `{...}` and `<...>` when referenced as operands in [[Filter expression|Introduction to Filters]].
|
||||||
|
|
||||||
|
* Text reference as `[search{$:/temp/search}]` or `[prefix{tiddlerA!!fieldname}]`
|
||||||
|
* Variable reference as `[search<currentTiddler>]`
|
||||||
|
|
||||||
|
! Variables and Macros
|
||||||
|
|
||||||
|
[[Variables|Variables in WikiText]] and [[macros|Macros in WikiText]] are indeed the same thing. Macros are just variables that have their parameters substituted before use.
|
||||||
|
|
||||||
|
! Textual Substitution
|
||||||
|
|
||||||
|
* `$parametername$` - for [[macor parameters|Macros in WikiText]]
|
||||||
|
```
|
||||||
|
\define mysamplemacro(name:"Bugs Bunny",address:"Rabbit Hole Hill")
|
||||||
|
Hi, I'm $name$ and I live in $address$
|
||||||
|
\end
|
||||||
|
```
|
||||||
|
|
||||||
|
* `$(variablename)$` - for variable substitutions ''within macros''
|
||||||
|
```
|
||||||
|
\define mysamplemacro2()
|
||||||
|
Hi, I'm $(name)$ and I live in $(address)$
|
||||||
|
\end
|
||||||
|
|
||||||
|
<$set name="name" value="Bugs Bunny">
|
||||||
|
<$set name="address" value="Rabbit Hole Hill">
|
||||||
|
<<mysamplemacro2>>
|
||||||
|
</$set></$set>
|
||||||
|
```
|
||||||
|
The differents between textual substitution and other syntax:
|
||||||
|
|
||||||
|
* Textual substitution is performed before the macro is parsed, the values are inserted into the target.
|
||||||
|
* While the `<<...>>` syntax is a transclusion, where the "WikiText" is inserted and rendered separately.
|
||||||
|
* Textual substitution behaves as text. So that they can be combined with other text, and the usage should include all braces like :
|
||||||
|
** `filter="[prefix[$:/$(a)$/$(b)$]]"` or
|
||||||
|
** `<$reveal ... text="$(c)$"> `
|
Loading…
Reference in New Issue
Block a user