mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-08-05 21:33:52 +00:00
Tweaks to #1678
This commit is contained in:
parent
e93d32cdd7
commit
42a3e31b1b
@ -3,7 +3,7 @@ title: $:/core/modules/widgets/vars.js
|
|||||||
type: application/javascript
|
type: application/javascript
|
||||||
module-type: widget
|
module-type: widget
|
||||||
|
|
||||||
This widget allows the user to set multiple variables in one go.
|
This widget allows multiple variables to be set in one go:
|
||||||
|
|
||||||
```
|
```
|
||||||
\define helloworld() Hello world!
|
\define helloworld() Hello world!
|
||||||
|
@ -6,15 +6,14 @@ caption: vars
|
|||||||
|
|
||||||
! Introduction
|
! Introduction
|
||||||
|
|
||||||
The ''vars'' widget allows you to set multiple variables in one go. It thereby reduces code complexity that would arise when setting
|
The ''vars'' widget allows multiple variables to be set in one operation. In some situations it can result in simpler code than using the more flexible SetWidget.
|
||||||
many variables using the [[SetWidget]].
|
|
||||||
|
|
||||||
! Content and Attributes
|
! Content and Attributes
|
||||||
|
|
||||||
The content of the `<$vars>` widget is the scope for the value assigned to the variable.
|
The content of the `<$vars>` widget is the scope for the value assigned to the variable.
|
||||||
|
|
||||||
|!Attribute |!Description |
|
|!Attribute |!Description |
|
||||||
|//{attributes not starting with $}// |Each attribute name specifies a variable name. The attribute value is used as variable assignement |
|
|//{attributes not starting with $}// |Each attribute name specifies a variable name. The attribute value is assigned to the variable |
|
||||||
|
|
||||||
! Examples
|
! Examples
|
||||||
|
|
||||||
@ -30,7 +29,7 @@ Using the `<$vars>` widget, this situation may be handled in the following way:
|
|||||||
</$vars>
|
</$vars>
|
||||||
```
|
```
|
||||||
|
|
||||||
In contrast, here is the same example, but using the `<$set>` widget instead:
|
In contrast, here is the same example using the `<$set>` widget:
|
||||||
|
|
||||||
```
|
```
|
||||||
<$set name="greeting" value="Hi" />
|
<$set name="greeting" value="Hi" />
|
||||||
@ -42,11 +41,10 @@ In contrast, here is the same example, but using the `<$set>` widget instead:
|
|||||||
</$set>
|
</$set>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
! Remarks
|
! Remarks
|
||||||
|
|
||||||
It should be noted that this widget differs from the set widget in the following ways:
|
It should be noted that this widget differs from the set widget in the following ways:
|
||||||
|
|
||||||
* You cannot specify a fallback (also known as "emptyValue")
|
* A fallback (also known as "emptyValue") cannot be specified
|
||||||
* You cannot use a filter to produce a conditional variable assignement
|
* Filters cannot be used to produce a conditional variable assignement
|
||||||
|
* Variable names must be literal strings
|
||||||
|
Loading…
x
Reference in New Issue
Block a user