1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-10-05 10:20:45 +00:00

Docs updates

This commit is contained in:
jeremy@jermolene.com 2022-09-09 12:05:08 +01:00
parent b751f7e793
commit 32a6b6bb90
3 changed files with 66 additions and 9 deletions

View File

@ -7,11 +7,11 @@ type: text/vnd.tiddlywiki
! Introduction
<<.from-version "5.3.0">> The genesis widget allows the dynamic construction of another widget, where the name and attributes of the new widget can be dynamically determined, without needing to be known in advance.
<<.from-version "5.3.0">> The <<.wlink GenesisWidget>> widget allows the dynamic construction of another widget, where the name and attributes of the new widget can be dynamically determined, without needing to be known in advance.
! Content and Attributes
The content of the `<$genesis>` widget is used as the content of the dynamically created widget.
The content of the <<.wlink GenesisWidget>> widget is used as the content of the dynamically created widget.
|!Attribute |!Description |
|$type |The type of widget or element to create (an initial `$` indicates a widget, otherwise an HTML element will be created) |

View File

@ -1,6 +1,49 @@
caption: parameters
created: 20220718192846556
modified: 20220718192846556
created: 20220909111836951
modified: 20220909111836951
tags: Widgets
title: ParametersWidget
type: text/vnd.tiddlywiki
<<.from-version "5.3.0">> The <<.wlink ParametersWidget>> widget is used within transcluded content to declare the parameters to be made available to the <<.wlink TranscludeWidget>> widget.
There are shortcuts for common scenarios that can often make it unnecessary to use the <<.wlink ParametersWidget>> widget directly:
* the `\parameters` [[pragma|Pragma]]
* the `\procedure` [[pragma|Pragma]] for declaring procedure
* the `\widgets` [[pragma|Pragma]] for declaring custom widgets
* the `_parameters` field of tiddlers containing [[Global Definitions]]
The <<.wlink ParametersWidget>> widget must be used directly in the following situations:
* When the default value of a parameter must be computed dynamically
* When the `$depth` attribute is used to retrieve parameters from a parent transclusion (see below)
! Content and Attributes
The content of the <<.wlink ParametersWidget>> widget is the scope within which the values of the parameters can be accessed as ordinary variables.
|!Attribute |!Description |
|$depth |The index of the parent transclusion from which to obtain the parameters (defaults to 1). See below |
|//{attributes not starting with $}// | |Any attributes that do not start with a dollar are used as parameters, with the value specifying the default to be used for missing parameters |
|//{other attributes starting with $}// | |Other attributes starting with a single dollar sign are reserved for future use |
|//{attributes starting with $$}// | |Attributes starting with two dollar signs are used as parameters to the transclusion, but with the name changed to use a single dollar sign. The value specifies the default to be used for missing parameters |
<<.note "Note the special treatment required for parameters names that start with a `$`; this can be avoided by using one of the pragmas">>
!! `$depth` Attribute
By default, the <<.wlink ParametersWidget>> widget retrieves parameters from the immediate parent transclusion. The `$depth` attribute permits access to the parameters of parent transclusions by specifying an index to the parent to be inspected. This is useful in some situations where an intervening transclusion prevents immediate access to desired parameters.
! Examples
Here the <<.wlink ParametersWidget>> widget is used to declare a parameter whose default value is transcluded from another tiddler.
<$macrocall $name='wikitext-example-without-html'
src="""\procedure mymacro
<$parameters name={{$:/SiteTitle}} age="21">
My name is <<name>> and my age is <<age>>.
</$parameters>
\end
<$transclude $variable="mymacro" age="19"/>"""/>

View File

@ -1,6 +1,6 @@
caption: transclude
created: 20130824142500000
modified: 20220718192846556
modified: 20220909111836951
tags: Widgets
title: TranscludeWidget
type: text/vnd.tiddlywiki
@ -49,7 +49,7 @@ Modern mode is recommended for use in new applications.
|$subtiddler |subtiddler |Optional SubTiddler title when the target tiddler is a [[plugin|Plugins]] (see below) |
|$mode |mode |Override the default parsing mode for the transcluded text to "block" or "inline" |
|$type | |Optional ContentType used when transcluding variables, indexes or fields other than the ''text'' field|
|$output |ContentType for the output rendering (defaults to `text/html`, can also be `text/plain` or `text/raw`) |
|$output |- |ContentType for the output rendering (defaults to `text/html`, can also be `text/plain` or `text/raw`) |
|$recursionMarker |recursionMarker |Set to ''no'' to prevent creation of [[Legacy Transclusion Recursion Marker]] (defaults to ''yes'') |
|//{attributes not starting with $}// | |Any other attributes that do not start with a dollar are used as parameters to the transclusion |
|//{other attributes starting with $}// | |Other attributes starting with a single dollar sign are reserved for future use |
@ -68,7 +68,7 @@ The basic operation of the <<.wlink TranscludeWidget>> widget is as follows:
! Transclusion Parameters
Named string parameters can be passed to the <<.wlink TranscludeWidget>> widget. They are then made available as variables within the transcluded text. Parameters are only supported in modern mode.
Named string parameters can be passed to the <<.wlink TranscludeWidget>> widget. They are made available as variables within the transcluded text. Parameters are only supported in modern mode.
When invoking a transclusion, parameters are specified as additional attributes that do not start with a dollar sign `$`:
@ -111,7 +111,7 @@ Transcluded content can define special named locations called slots. At the poin
Slots work very similarly to parameters except that they can contain structured wikitext, and not just plain text.
For example, here we transclude the tiddler "Example" while passing wikitext blocks to fill the slots called "positive" and "negative":
For example, here we transclude the tiddler "Example" while using the <<.wlink FillWidget>> widget to pass wikitext blocks to fill the slots called "positive" and "negative":
```
<$transclude $tiddler="Example">
@ -124,7 +124,7 @@ For example, here we transclude the tiddler "Example" while passing wikitext blo
</$transclude>
```
Here is the contents of the tiddler "Example":
The tiddler "Example" uses the <<.wlink SlotWidget>> widget to specify the slots to be filled:
```
<ol>
@ -133,6 +133,20 @@ Here is the contents of the tiddler "Example":
</ol>
```
The output will be equivalent to:
```
<ol>
<li>
<h1>This is positive</h1>
</li>
<li>
<h3>This is negative</h3>
</li>
</ol>
```
! Missing Transclusion Targets
The TranscludeWidget uses the special slot `ts-missing` to specify the content to be rendered if the transclusion target is not defined (i.e. a missing tiddler or a missing field).