This page is part of a static HTML representation of the TiddlyWiki at https://tiddlywiki.com/

DataWidget

 7th May 2024 at 10:19pm

Introduction

The data widget is used with the $testcase widget and the Innerwiki Plugin to specify payload tiddlers that are to be included in the test case or innerwiki.

Content and Attributes

The content of the data widget is ignored. It supports the following attributes:

AttributeDescription
$tiddlerOptional title of a tiddler to be used as a payload tiddler (optional)
$filterOptional filter string identifying tiddlers to be used as payload tiddlers (optional)
$compound-tiddlerOptional title of a tiddler containing payload tiddlers in text/vnd.tiddlywiki-multiple format (see below)
any attribute
not starting
with $
Field values to be assigned to the payload tiddler(s)

The data widget is not rendered when used within the $testcase widget or the Innerwiki Plugin but for ease of testing, when used elsewhere it renders a JSON representation of the payload tiddlers.

Without any of the attributes $tiddler, $filter or $compound-tiddler, any attributes whose name does not start with $ are used as the field values for creating a single new tiddler.

Using the data widget to create a tiddler with the title "Epsilon" and the text "Theta"
titleOutput
[
    {
        "title": "Epsilon",
        "text": "Theta"
    }
]

If any of the attributes $tiddler, $filter or $compound-tiddler are specified then they are used to generate base tiddlers that are then modified with the addition of fields derived from any attributes whose name does not start with $.

The attribute $tiddler is used to ingest a single tiddler from the wiki containing the data widget:

Using the data widget to create a tiddler that is a copy of the tiddler "Hello" with the addition of the field "custom" set to "Alpha"
titleOutput
[
    {
        "title": "Hello",
        "modifier": "JoeBloggs",
        "text": "This is the Hello tiddler",
        "custom": "Alpha"
    }
]

The attribute $filter is used to ingest multiple tiddlers from the wiki containing the data widget:

Using the data widget to create copies of all the tiddlers with the title prefix "Day: T", adding the field "custom" set to "Beta"
titleOutput
[
    {
        "title": "Day: Thursday",
        "text": "Today is Thursday",
        "custom": "Beta"
    },
    {
        "title": "Day: Tuesday",
        "text": "Today is Tuesday",
        "custom": "Beta"
    }
]

Compound Tiddlers

Compound tiddlers provide a way to easily create multiple tiddlers from within a single tiddler. They are contained in tiddlers of type text/vnd.tiddlywiki-multiple. The text field consists of a series of tiddlers in the same format as .tid files, each separated by a line containing a single + character.

Using the data widget to import a tiddler stored in a compound tiddler
titleOutput
[
    {
        "title": "Payload Tiddler",
        "tags": "Alpha Beta Gamma",
        "text": "This is a payload tiddler from a compound tiddler",
        "custom": "Alpha"
    }
]