mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-04-30 23:56:54 +00:00
Extend the set widget with tiddler, field and index attributes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
caption: set
|
||||
created: 20131115182700000
|
||||
modified: 20161017122456014
|
||||
modified: 20170712153850528
|
||||
tags: Widgets
|
||||
title: SetWidget
|
||||
type: text/vnd.tiddlywiki
|
||||
@@ -16,9 +16,12 @@ The content of the `<$set>` widget is the scope for the value assigned to the va
|
||||
|!Attribute |!Description |
|
||||
|name |The name of the variable to assign (defaults to "currentTiddler") |
|
||||
|value |The value to assign to the variable if the filter is missing or not empty |
|
||||
|tiddler |<<.from-version "5.1.15">> Optional title of the tiddler from which to read the value |
|
||||
|field |<<.from-version "5.1.15">> Optional field of the tiddler from which to read the value (only used if ''tiddler'' is used) |
|
||||
|index |<<.from-version "5.1.15">> Optional index of the tiddler from which to read the value (only used if ''tiddler'' is used) |
|
||||
|filter |An optional filter to be evaluated and assigned to the variable (see below) |
|
||||
|select |<<.from-version "5.1.14">> An optional zero-based index of the item to return from the filter output (see below) |
|
||||
|emptyValue |The value to assign to the variable if the filter is present and evaluates to an empty list (see below) |
|
||||
|emptyValue |The value to assign to the variable if the specified value is missing or empty (see below) |
|
||||
|
||||
!! Simple Variable Assignment
|
||||
|
||||
@@ -67,3 +70,21 @@ This form of the set variable widget evaluates the filter and assigns the result
|
||||
<$text text=<<myVariable>>/>
|
||||
</$set>
|
||||
```
|
||||
|
||||
!! Transcluded Variable Assignment
|
||||
|
||||
<<.from-version "5.1.15">> This form of the set variable widget obtains the value to assign to the variable from a value in a tiddler field or index. For example:
|
||||
|
||||
```
|
||||
<$set name="myVariable" tiddler="HelloThere" field="text">
|
||||
<$text text=<<myVariable>>/>
|
||||
</$set>
|
||||
```
|
||||
|
||||
The example above could also be written as `<$set name="myVariable" value={{HelloThere!!text}}>`. The advantage of using the ''tiddler'' attribute is that the tiddler title and field or index can themselves be computed. For example:
|
||||
|
||||
```
|
||||
<$set name="myVariable" tiddler=<<myTiddler>> field={{$:/currentField}}>
|
||||
<$text text=<<myVariable>>/>
|
||||
</$set>
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user