mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-04-30 18:26:47 +00:00
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
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
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>"""/>
|
||||
Reference in New Issue
Block a user