1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-08-06 11:10:37 +00:00
TiddlyWiki5/editions/tw5.com/tiddlers/pragmas/Pragma_ _widget.tid

27 lines
1.3 KiB
Plaintext
Raw Normal View History

2022-10-09 12:54:33 +00:00
created: 20221009121950630
modified: 20230419103154329
2022-10-09 12:54:33 +00:00
tags: Pragmas
title: Pragma: \widget
type: text/vnd.tiddlywiki
2022-10-09 16:34:22 +00:00
<<.from-version "5.3.0">> The ''\widget'' [[pragma|Pragmas]] is used to [[define custom widgets|Custom Widgets]]. It is a shortcut syntax for the SetVariableWidget with an implicit ParametersWidget.
2022-10-09 12:54:33 +00:00
The usual form allows custom widgets to span multiple lines:
```
\widget <widget-name>(<param-name>[:<param-default-value>],<param-name>[:<param-default-value>]...)
<multiple-line-definition-text>
\end [<widget-name>]
2022-10-09 12:54:33 +00:00
```
Note that the `\end` marker can optionally specify the name of the widget to which it relates which allows widget definitions to be nested.
2022-10-09 12:54:33 +00:00
There is also a single line form for shorter widgets:
```
\widget <widget-name>(<param-name>[:<param-default-value>],<param-name>[:<param-default-value>]...) <single-line-definition-text>
```
The first line of the definition specifies the widget name and any parameters. Each parameter has a name and, optionally, a default value that is used if no value is supplied on a particular call to the widget. The lines that follow contain the text of the widget text (i.e. the snippet represented by the widget name), until `\end` appears on a line by itself:
See [[Custom Widgets]] for more details.