Move docs for 5.1.5 release

This commit is contained in:
Jermolene 2014-11-26 11:22:20 +00:00
parent a5c7089bcf
commit 7d46afc7b2
32 changed files with 109 additions and 405 deletions

View File

@ -1,31 +0,0 @@
caption: action-sendmessage
created: 20141008134309742
modified: 20141107132122081
tags: Widgets ActionWidgets
title: ActionSendMessageWidget
type: text/vnd.tiddlywiki
! Introduction
The ''action-sendmessage'' widget is an [[action widget|ActionWidgets]] that sends a [[message|WidgetMessages]] back up the widget tree. ActionWidgets are used within triggering widgets such as the ButtonWidget.
! Content and Attributes
The ''action-sendmessage'' widget is invisible. Any content within it is ignored.
|!Attribute |!Description |
|$message |The message to send (eg, [[WidgetMessage: tm-new-tiddler]]) |
|$param |Optional parameter string whose meaning is dependent on the message being sent |
|//{any attributes not starting with $}// |Multiple additional named parameters that are attached to the message |
! Examples
Here is an example of button that displays both a notification and a wizard, and creates a new tiddler with tags and text:
<$macrocall $name='wikitext-example-without-html'
src='<$button>
<$action-sendmessage $message="tm-modal" $param="SampleWizard"/>
<$action-sendmessage $message="tm-notify" $param="SampleNotification"/>
<$action-sendmessage $message="tm-new-tiddler" title="This is newly created tiddler" tags="OneTag [[Another Tag]]" text=<<now "Today is DDth, MMM YYYY">>/>
Click me!
</$button>'/>

View File

@ -1,41 +0,0 @@
title: EditTextWidget
created: 201310241419
modified: 20141025085449609
tags: Widgets
caption: edit-text
! Introduction
The edit text widget provides a user interface in the browser for editing text tiddler fields. The editing element is dynamically bound to the underlying tiddler value: changes to the tiddler are instantly reflected, and any edits are instantly propogated.
By default, the edit text widget generates a `<textarea>` as the HTML editing element when the `text` field is edited, and a `<input type="text">` element otherwise. This behaviour can be overridden with the `tag` and `type` attributes.
! Content and Attributes
The content of the `<$edit-text>` widget is ignored.
|!Attribute |!Description |
|tiddler |The tiddler to edit (defaults to the CurrentTiddler) |
|field |The field to edit (defaults to `text`). Takes precedence over the `index` attribute |
|index |The index to edit |
|default |The default text to be provided when the target tiddler doesn't exist |
|class |A CSS class to be assigned to the generated HTML editing element |
|placeholder |Placeholder text to be displayed when the edit field is empty |
|focusPopup |Title of a state tiddler for a popup that is displayed when the editing element has focus |
|tag |Overrides the generated HTML editing element tag. Use `textarea` for a multi-line editor |
|type |Overrides the generated HTML editing element `type` attribute |
|size |The size of the input field (in characters) |
|autoHeight |Either "yes" or "no" to specify whether to automatically resize `textarea` editors to fit their content (defaults to "yes") |
|minHeight |Minimum height for automatically resized `textarea` editors, specified in CSS length units such as "px", "em" or "%" |
! Notes
One trap to be aware of is that the edit text widget cannot be used to edit a field of the tiddler that contains it. Each keypress results in the tiddler being re-rendered, which loses the cursor position within the text field.
Instead, place the edit text widget in a [[template|TemplateTiddlers]] that references the tiddler you want to modify.
For example, if you wanted to edit the value of the "myconfig" field of the tiddler "AppSettings", you might do so by creating a separate tiddler "ChangeAppSettings" that contains the following:
```
<$edit-text tiddler="AppSettings" field="myconfig"/>
```

View File

@ -1,17 +0,0 @@
created: 20140410103123179
modified: 20140410103123179
tags: Filters CommonFilters
caption: search
title: FilterOperator: search
type: text/vnd.tiddlywiki
The ''search'' filter operator filters the current list to leave only those tiddlers that include the operand text in their title, body or tags. Preceding the operator with `!` returns all tiddlers that do not include the specified text. The search is case-insenstive.
Optionally, a field can be specified to restrict the search.
For example:
|!Filter String |!Description |
|`[search[alsatian]]` |Returns a list of the tiddlers containing the text "alsatian" |
|`[all[shadows]search[alsatian]]` |Returns a list of the shadow tiddlers containing the text "alsatian" |
|`[search:caption[spaniel]]` |Returns a list of the tiddlers containing the text "spaniel" in their caption field |

View File

@ -1,57 +0,0 @@
title: SetWidget
created: 201311151827
modified: 20141113212520422
tags: Widgets
caption: set
! Introduction
The set variable widget assigns a value to a specified [[variable|WidgetVariables]]. The new value of the variable is availale to the content within the set variable widget.
! Content and Attributes
The content of the `<$set>` widget is the scope for the value assigned to the variable.
|!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 |
|filter |An optional filter to be evaluated and assigned to the variable (see below) |
|emptyValue |The value to assign to the variable if the filter is present and evaluates to an empty list (see below) |
!! Simple Variable Assignment
The simplest way of using set variable widget assigns a string to a variable. The following example assigns a literal string
```
<$set name="myVariable" value="Some text">
<$text text=<<myVariable>>/>
</$set>
```
Both the name and value attributes can be transcluded. For example:
```
<$set name=<<anotherVariable>> value={{template!!text}}>
<$text text=<<myVariable>>/>
</$set>
```
!! Conditional Variable Assignment
This form of the set variable widget chooses one of two specified values according to whether a filter evaluates to an empty list. Here's an example that sets a variable according to whether the current tiddler is called "myMagicTitle":
```
<$set name="myVariable" filter="[all[current]field:title[myMagicTitle]]" value="It's magic" emptyValue="It's not magic">
<$text text=<<myVariable>>/>
</$set>
```
!! Filtered List Variable Assignment
This form of the set variable widget evaluates the filter and assigns the result to the variable as a space-separated list (using double square brackets for titles containing spaces).
```
<$set name="myVariable" filter="[tag[Introduction]]">
<$text text=<<myVariable>>/>
</$set>
```

View File

@ -1,110 +0,0 @@
created: 20130825214200000
modified: 20141113122142639
tags: [[TiddlyWiki on Node.js]]
title: TiddlyWikiFolders
type: text/vnd.tiddlywiki
As well as traditional single file wikis, [[TiddlyWiki on Node.js]] supports wikis that are stored as a folder of individual tiddler files.
! Wiki folder files and folders
Wiki folders can contain the following files and folders:
* ''tiddlywiki.info'' - JSON file containing metadata for the wiki
* ''\tiddlers'' - folder containing tiddler files comprising the wiki
* ''\plugins'' - folder containing [[plugin folders|PluginMechanism]] to be included in the wiki
Only the ''tiddlywiki.info'' file is required, the ''tiddlers'' and ''plugins'' folders are optional. Any files and folders not listed above are ignored.
!! Content of `tiddlywiki.info` file
The `tiddlywiki.info` file in a wiki folder contains a JSON object comprising the following fields:
* ''plugins'' - an array of plugin names to be included in the wiki
* ''themes'' - an array of theme names to be included in the wiki
* ''languages'' - an array of language names to be included in the wiki
* ''includeWikis'' - an array of references to external wiki folders to be included in the wiki
* ''build'' - a hashmap of named build targets, each defined by an array of command tokens (see BuildCommand)
* ''config'' - an optional hashmap of configuration options (see below)
!!! ''includeWikis''
The entries in the ''includeWikis'' array can be either a string specifying the relative path to the wiki, or an object with the following fields:
* ''path'' - relative path to wiki folder
* ''read-only'' - set //true// to prevent the tiddlers in the included wiki from being modified. The modifications will be written to the directory specified in ''default-tiddler-location'', described below
!!! ''build''
Note that the build targets of included wikis are merged if a target of that name isn't defined in the current `tiddlywiki.info` file.
!!! ''config''
Configuration options include:
* ''default-tiddler-location'' - a string path to the default location for the filesystem adaptor to save new tiddlers (resolved relative to the wiki folder)
* ''retain-original-tiddler-path'' - If true, the server will generate a tiddler [[$:/config/OriginalTiddlerPaths]] containing the original file paths of each tiddler in the wiki
!!! Example
For example:
```
{
"plugins": [
"tiddlywiki/tiddlyweb",
"tiddlywiki/filesystem"
],
"includeWikis": [
"../tw5.com"
],
"build": {
"index": [
"--rendertiddler","$:/core/save/all","index.html","text/plain"],
"favicon": [
"--savetiddler","$:/favicon.ico","favicon.ico",
"--savetiddler","$:/green_favicon.ico","static/favicon.ico"]
},
"config": {
"retain-original-tiddler-path": true
}
}
```
!! Content of `tiddlers` folder
All the TiddlerFiles in the `tiddlers` folder are read into the wiki at startup. Sub-folders are scanned recursively for TiddlerFiles.
Sub-folders within the `tiddlers` folder can also be given a `tiddlywiki.files` JSON file that overrides the default processing for that folder. The file format is illustrated with this example from the D3 plugin:
```
{
"tiddlers": [
{
"file": "d3.min.js",
"fields": {
"type": "application/javascript",
"title": "$:/plugins/tiddlywiki/d3/d3.js",
"module-type": "library"
},
"prefix": "var d3;if($tw.browser){\n",
"suffix": "}\nexports.d3 = d3;\n"
},
{
"file": "cloud/d3.layout.cloud.js",
"fields": {
"type": "application/javascript",
"title": "$:/plugins/tiddlywiki/d3/d3.layout.cloud.js",
"module-type": "library"
}
}
]
}
```
The JSON data consists of an object with a `tiddlers` property that contains an array of information about each tiddler to be loaded into the wiki. That information consists of:
* `file`: the relative or absolute path to the file to include
* `fields`: an object containing fields that override any provided in the tiddler file
* `prefix` & `suffix`: (optional) specify strings to be prefixed and suffixed to the tiddler file text content

View File

@ -1,34 +0,0 @@
title: TimelineMacro
tags: Macros
modified: 20141103172520228
caption: timeline
The timeline macro produces a list of tiddlers in reverse chronological order of modification date that is grouped by the date of the day of modification.
! Parameters
|!Position |!Name |!Description |!Default |
|1st |limit |The maximum number of tiddlers to list (see below) |100 |
|2nd |format |A DateFormat string for formatting the date |DDth MMM YYYY |
|3rd |subfilter |A subfilter to include in the timeline filter (see below) | |
|4th |dateField |Optional name of date field to use |modified |
The subfilter and limit parameters are spliced into the filter string like this:
```
[!is[system]$subfilter$has[modified]!sort[modified]limit[$limit$]eachday[modified]]
```
To restrict the timeline to a particular tag, the subfilter can be set to something like `tag[mytag]`:
```
<<timeline limit:10 subfilter:"tag[mytag]">>
```
Note that the timeline macro does not truncate the entries for a particular day, instead always displaying all the tiddlers under each displayed day heading. This means that the limit parameter works in an unexpected way because it is possible for more than the specified number of tiddlers to be displayed.
! Examples
<$macrocall $name="wikitext-example-without-html"
src="<<timeline limit:30 format:'DD/MM/YYYY'>>
"/>

View File

@ -1,16 +0,0 @@
created: 20140811112201235
modified: 20141110133723696
tags: Messages
title: WidgetMessage: tm-download-file
type: text/vnd.tiddlywiki
caption: tm-download-file
The download file message causes the current saver module to prompt the user to download the result of parsing a specified template tiddler as a file. It requires the following properties on the `event` object:
|!Name |!Description |
|param |Title of a tiddler to use as a template for the new tiddler |
|paramObject |Optional hashmap of variable values to use for the rendering |
The download file message is usually generated with the ButtonWidget.
The download file message is handled by the TiddlyWiki core SyncMechanism which invokes the current [[SaverModule|SaverModules]].

View File

@ -1,32 +0,0 @@
created: 20140811112133701
modified: 20141107142803042
tags: Messages
title: WidgetMessage: tm-modal
type: text/vnd.tiddlywiki
caption: tm-modal
The modal message displays a specified tiddler in a modal overlay that dims the main page. It requires the following properties on the `event` object:
|!Name |!Description |
|param |Title of the tiddler to be displayed |
|paramObject |Hashmap of variables to be provided to the modal |
The "currentTiddler" variable is set to the title of the modal tiddler, but can be overridden by specifying a different value in `paramObject`.
The modal message is usually generated with the ButtonWidget. The modal message is handled by the TiddlyWiki core.
! Example
Here is an example of displaying a modal and passing parameters to it:
<$macrocall $name='wikitext-example-without-html'
src='Your name: <$edit-text tiddler="$:/temp/yourName" tag="input" default="Your name"/>
Your message:
<$edit-text tiddler="$:/temp/yourMessage" default="Your message"/>
<$button>
<$action-sendmessage $message="tm-modal" $param="SampleModal" yourName={{$:/temp/yourName}} yourMessage={{$:/temp/yourMessage}}/>
Click me!
</$button>'/>

View File

@ -1,29 +0,0 @@
caption: tm-new-tiddler
created: 20140226194405353
modified: 20141107132122081
tags: Messages navigator-message
title: WidgetMessage: tm-new-tiddler
type: text/vnd.tiddlywiki
The new tiddler message creates a new draft tiddler and adds it to the current story. It requires the following properties on the `event` object:
|!Name |!Description |
|param |The optional title of a tiddler to use as a template for the new tiddler |
|paramObject |Optional hashmap of additional tiddler fields |
|navigateFromTitle |Title of the tiddler from which the navigation to the new tiddler was initiated |
The title for the draft tiddler is chosen according to these rules:
* If a hashmap was used and a title field was specified, use that title
* If a template tiddler was used, use the title of the template tiddler, making it unique with a numeric suffix
* Otherwise, generate a new title based on the default new tiddler title with a numeric suffix to make it unique
The new tiddler message is usually generated with the ButtonWidget or ActionSendMessageWidget and is handled by the NavigatorWidget.
! Example
To make a button that creates new tiddlers tagged "task", create a tiddler called "TaskTemplate" with that tag, and then make your button like this:
```
<$button message="tm-new-tiddler" param="TaskTemplate">New Task</$button>
```

View File

@ -1,16 +0,0 @@
created: 20140811112325641
modified: 20141110133723696
tags: Messages
title: WidgetMessage: tm-save-wiki
type: text/vnd.tiddlywiki
caption: tm-save-wiki
The save wiki message causes the current saver module to perform a full save operation. The save operation can involve user interaction. It requires the following properties on the `event` object:
|!Name |!Description |
|param |Title of a tiddler to use as a template for rendering the wiki (defaults to `$:/core/save/all`) |
|paramObject |Optional hashmap of variable values to use for the rendering |
The save wiki message is usually generated by the ButtonWidget.
The save wiki message is handled by the TiddlyWiki core SyncMechanism which invokes the current [[SaverModule|SaverModules]].

View File

@ -1,5 +1,5 @@
created: 20130825214200000
modified: 20141013204930183
modified: 20141113122142639
tags: [[TiddlyWiki on Node.js]]
title: TiddlyWikiFolders
type: text/vnd.tiddlywiki
@ -23,18 +23,31 @@ The `tiddlywiki.info` file in a wiki folder contains a JSON object comprising th
* ''plugins'' - an array of plugin names to be included in the wiki
* ''themes'' - an array of theme names to be included in the wiki
* ''languages'' - an array of language names to be included in the wiki
* ''includeWikis'' - an array of relative paths to external wiki folders to be included in the wiki
* ''includeWikis'' - an array of references to external wiki folders to be included in the wiki
* ''build'' - a hashmap of named build targets, each defined by an array of command tokens (see BuildCommand)
* ''config'' - an optional hashmap of configuration options (see below)
!!! ''includeWikis''
The entries in the ''includeWikis'' array can be either a string specifying the relative path to the wiki, or an object with the following fields:
* ''path'' - relative path to wiki folder
* ''read-only'' - set //true// to prevent the tiddlers in the included wiki from being modified. The modifications will be written to the directory specified in ''default-tiddler-location'', described below
!!! ''build''
Note that the build targets of included wikis are merged if a target of that name isn't defined in the current `tiddlywiki.info` file.
!!! ''config''
Configuration options include:
* ''default-tiddler-location'' - a string path to the default location for the filesystem adaptor to save new tiddlers (resolved relative to the wiki folder)
* ''retain-original-tiddler-path'' - If true, the server will generate a tiddler [[$:/config/OriginalTiddlerPaths]] containing the original file paths of each tiddler in the wiki
!!! Example
For example:
```

View File

@ -1,15 +1,17 @@
created: 20140410103123179
modified: 20141117224755646
modified: 20140410103123179
tags: Filters CommonFilters
caption: search
title: FilterOperator: search
type: text/vnd.tiddlywiki
The ''search'' filter operator filters the current list to leave only those tiddlers that include the search terms specified in the operand text in their title, body or tags. Preceding the operator with `!` returns all tiddlers that do not include the specified search terms. The search is case-insenstive.
The ''search'' filter operator filters the current list to leave only those tiddlers that include the operand text in their title, body or tags. Preceding the operator with `!` returns all tiddlers that do not include the specified text. The search is case-insenstive.
Optionally, a field can be specified to restrict the search.
For example:
|!Filter String |!Description |
|`[search[alsatian]]` |Returns a list of the tiddlers containing the text "alsatian" |
|`[search[alsatian dog]]` |Returns a list of the tiddlers containing the text "alsatian" and "dog" (not necessarily immediately adjacent to one another) |
|`[all[shadows]search[alsatian]]` |Returns a list of the shadow tiddlers containing the text "alsatian" |
|`[search:caption[spaniel]]` |Returns a list of the tiddlers containing the text "spaniel" in their caption field |

View File

@ -7,6 +7,10 @@ type: text/vnd.tiddlywiki
Welcome to ~TiddlyWiki, a versatile note-taking web application you can download for free, store wherever you like and customise however you wish. Use it to capture, organise and share your notes in ways that word processors and other note-taking tools cannot.
<$button class="tc-btn-invisible" to="Introduction Video" style="fill:red;">
{{$:/core/images/video}} Watch a video introduction
</$button>
~TiddlyWiki is designed to be non-linear, structuring content with stories, tags, hyperlinks, and other features. You can organise and retrieve your notes in ways that conform to your personal thought patterns, rather than feel chained to one preset organisational structure.
You can use ~TiddlyWiki as a single file that you view and edit through any web browser, whether you are online or offline. Or you can use it as a powerful [[Node.js application|TiddlyWiki on Node.js]] that stores each of your notes as a separate file.

View File

@ -1,6 +1,6 @@
title: TimelineMacro
tags: Macros
modified: 20141015165343893
modified: 20141103172520228
caption: timeline
The timeline macro produces a list of tiddlers in reverse chronological order of modification date that is grouped by the date of the day of modification.
@ -11,6 +11,7 @@ The timeline macro produces a list of tiddlers in reverse chronological order of
|1st |limit |The maximum number of tiddlers to list (see below) |100 |
|2nd |format |A DateFormat string for formatting the date |DDth MMM YYYY |
|3rd |subfilter |A subfilter to include in the timeline filter (see below) | |
|4th |dateField |Optional name of date field to use |modified |
The subfilter and limit parameters are spliced into the filter string like this:

View File

@ -1,5 +1,5 @@
created: 20140811112201235
modified: 20140811115140378
modified: 20141110133723696
tags: Messages
title: WidgetMessage: tm-download-file
type: text/vnd.tiddlywiki
@ -9,6 +9,7 @@ The download file message causes the current saver module to prompt the user to
|!Name |!Description |
|param |Title of a tiddler to use as a template for the new tiddler |
|paramObject |Optional hashmap of variable values to use for the rendering |
The download file message is usually generated with the ButtonWidget.

View File

@ -1,5 +1,5 @@
created: 20140811112133701
modified: 20140811120203685
modified: 20141107142803042
tags: Messages
title: WidgetMessage: tm-modal
type: text/vnd.tiddlywiki
@ -9,5 +9,24 @@ The modal message displays a specified tiddler in a modal overlay that dims the
|!Name |!Description |
|param |Title of the tiddler to be displayed |
|paramObject |Hashmap of variables to be provided to the modal |
The "currentTiddler" variable is set to the title of the modal tiddler, but can be overridden by specifying a different value in `paramObject`.
The modal message is usually generated with the ButtonWidget. The modal message is handled by the TiddlyWiki core.
! Example
Here is an example of displaying a modal and passing parameters to it:
<$macrocall $name='wikitext-example-without-html'
src='Your name: <$edit-text tiddler="$:/temp/yourName" tag="input" default="Your name"/>
Your message:
<$edit-text tiddler="$:/temp/yourMessage" default="Your message"/>
<$button>
<$action-sendmessage $message="tm-modal" $param="SampleModal" yourName={{$:/temp/yourName}} yourMessage={{$:/temp/yourMessage}}/>
Click me!
</$button>'/>

View File

@ -1,6 +1,6 @@
caption: tm-new-tiddler
created: 20140226194405353
modified: 20141008142952355
modified: 20141107132122081
tags: Messages navigator-message
title: WidgetMessage: tm-new-tiddler
type: text/vnd.tiddlywiki
@ -8,14 +8,15 @@ type: text/vnd.tiddlywiki
The new tiddler message creates a new draft tiddler and adds it to the current story. It requires the following properties on the `event` object:
|!Name |!Description |
|param |Either the title of a tiddler to use as a template for the new tiddler or a hashmap of tiddler fields |
|param |The optional title of a tiddler to use as a template for the new tiddler |
|paramObject |Optional hashmap of additional tiddler fields |
|navigateFromTitle |Title of the tiddler from which the navigation to the new tiddler was initiated |
The title for the draft tiddler is chosen according to these rules:
* If a hashmap was used and a title field was specified, use that title
* If a hashmap was used without a title field, use a default title, if necessary making it unique with a numeric suffix
* If a template tiddler was used, use the title of the template tiddler, if necessary making it unique with a numeric suffix
* If a template tiddler was used, use the title of the template tiddler, making it unique with a numeric suffix
* Otherwise, generate a new title based on the default new tiddler title with a numeric suffix to make it unique
The new tiddler message is usually generated with the ButtonWidget or ActionSendMessageWidget and is handled by the NavigatorWidget.

View File

@ -1,11 +1,15 @@
created: 20140811112325641
modified: 20140811115149288
modified: 20141110133723696
tags: Messages
title: WidgetMessage: tm-save-wiki
type: text/vnd.tiddlywiki
caption: tm-save-wiki
The save wiki message causes the current saver module to perform a full save operation. The save operation can involve user interaction.
The save wiki message causes the current saver module to perform a full save operation. The save operation can involve user interaction. It requires the following properties on the `event` object:
|!Name |!Description |
|param |Title of a tiddler to use as a template for rendering the wiki (defaults to `$:/core/save/all`) |
|paramObject |Optional hashmap of variable values to use for the rendering |
The save wiki message is usually generated by the ButtonWidget.

View File

@ -1,6 +1,6 @@
caption: action-sendmessage
created: 20141008134309742
modified: 20141008162952455
modified: 20141107132122081
tags: Widgets ActionWidgets
title: ActionSendMessageWidget
type: text/vnd.tiddlywiki
@ -16,7 +16,7 @@ The ''action-sendmessage'' widget is invisible. Any content within it is ignored
|!Attribute |!Description |
|$message |The message to send (eg, [[WidgetMessage: tm-new-tiddler]]) |
|$param |Optional parameter string whose meaning is dependent on the message being sent |
|//{any attributes not starting with $}// |Multiple parameters that are attached to the message if the `$param` attribute is not provided |
|//{any attributes not starting with $}// |Multiple additional named parameters that are attached to the message |
! Examples

View File

@ -1,6 +1,6 @@
title: EditTextWidget
created: 201310241419
modified: 201407250837
modified: 20141025085449609
tags: Widgets
caption: edit-text
@ -22,9 +22,11 @@ The content of the `<$edit-text>` widget is ignored.
|class |A CSS class to be assigned to the generated HTML editing element |
|placeholder |Placeholder text to be displayed when the edit field is empty |
|focusPopup |Title of a state tiddler for a popup that is displayed when the editing element has focus |
|tag |Overrides the generated HTML editing element tag |
|size |The size of the input field (in characters) |
|tag |Overrides the generated HTML editing element tag. Use `textarea` for a multi-line editor |
|type |Overrides the generated HTML editing element `type` attribute |
|size |The size of the input field (in characters) |
|autoHeight |Either "yes" or "no" to specify whether to automatically resize `textarea` editors to fit their content (defaults to "yes") |
|minHeight |Minimum height for automatically resized `textarea` editors, specified in CSS length units such as "px", "em" or "%" |
! Notes

View File

@ -1,6 +1,6 @@
title: SetWidget
created: 201311151827
modified: 201311151827
modified: 20141113212520422
tags: Widgets
caption: set
@ -13,5 +13,45 @@ The set variable widget assigns a value to a specified [[variable|WidgetVariable
The content of the `<$set>` widget is the scope for the value assigned to the variable.
|!Attribute |!Description |
|name |The name of the variable to assign |
|value |The value to assign to the variable |
|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 |
|filter |An optional filter to be evaluated and assigned to the variable (see below) |
|emptyValue |The value to assign to the variable if the filter is present and evaluates to an empty list (see below) |
!! Simple Variable Assignment
The simplest way of using set variable widget assigns a string to a variable. The following example assigns a literal string
```
<$set name="myVariable" value="Some text">
<$text text=<<myVariable>>/>
</$set>
```
Both the name and value attributes can be transcluded. For example:
```
<$set name=<<anotherVariable>> value={{template!!text}}>
<$text text=<<myVariable>>/>
</$set>
```
!! Conditional Variable Assignment
This form of the set variable widget chooses one of two specified values according to whether a filter evaluates to an empty list. Here's an example that sets a variable according to whether the current tiddler is called "myMagicTitle":
```
<$set name="myVariable" filter="[all[current]field:title[myMagicTitle]]" value="It's magic" emptyValue="It's not magic">
<$text text=<<myVariable>>/>
</$set>
```
!! Filtered List Variable Assignment
This form of the set variable widget evaluates the filter and assigns the result to the variable as a space-separated list (using double square brackets for titles containing spaces).
```
<$set name="myVariable" filter="[tag[Introduction]]">
<$text text=<<myVariable>>/>
</$set>
```