1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-25 19:17:19 +00:00
TiddlyWiki5/editions/tw5.com/tiddlers/widgets/SetMultipleVariablesWidget.tid
Jeremy Ruston d5f72cb282
Set multiple fields/variables/params using filters (#6130)
* Add action-setmultiplefields and setmultiplevariables, and extend action-sendmessage

* Add getfield operator

* Remove getfield operator

See discussion at https://github.com/Jermolene/TiddlyWiki5/pull/6130#issuecomment-949911439

* Add docs

* Adjust whitespace

* Add support for assigning multiple indexes to action-setmultiplefields
2021-10-27 11:20:11 +01:00

34 lines
1.2 KiB
Plaintext

caption: setmultiplevariables
created: 20211023162409163
modified: 20211023162409163
tags: Widgets
title: SetMultipleVariablesWidget
type: text/vnd.tiddlywiki
! Introduction
The setmultiplevariables widget assigns values to multiple [[variables|Variables]] where the names and values of the variables are specified as separate filter.
! Content and Attributes
The content of the `<$setmultiplevariables>` widget is the scope for the value assigned to the variable.
|!Attribute |!Description |
|$names |Filter evaluating to the names of a list of variables to assign |
|$values |Filter evaluating to the values corresponding to the list of names specified in `$names` |
! Examples
Here is an example of a convoluted way to display the values of the fields of the tiddler "HelloThere":
<$macrocall $name='wikitext-example-without-html'
src="""<$setmultiplevariables $names="[[HelloThere]fields[]addprefix[demo-]]" $values="[[HelloThere]fields[]] :map[[HelloThere]get<currentTiddler>]">
<ol>
<$list filter="[variables[]prefix[demo-]sort[]]">
<li>
''<$text text={{{ [<currentTiddler>removeprefix[demo-]] }}}/>'': <$text text={{{ [<currentTiddler>getvariable[]] }}}/>
</li>
</$list>
</ol>
</$setmultiplevariables>"""/>