For the curious, technical and tiddlywiki hacker, I just discovered something interesting, that provides additional code patterns to pack tiddlers.
- Don’t bother reading unless you want to hack, once I understand it better if any “cool tools” can be developed I will publish separately.
- I am possibly “late to the party”, but thought I would share anyway
- It involves being able to address and import tiddlers from within another tiddler.
Background;
- Plugins actually contain tiddlers in a JSON format. They have a plugin-type field of plugin, but they are just tiddlers, containing “subtiddlers”.
- Normally we access the tiddlers within plugins as shadow tiddlers.
- If we edit shadow tiddlers, they become tiddlers, with the same name but outside the plugin.
- You can list the shadow tiddlers within a plugin tiddler with the plugintiddlers Operator
- A few widgets allow the reference to a named subtiddler such as transclude and view widget.
- You need to give the tiddler name for which it is a subtiddler of.
- These also accept a field parameter to target any field within a shadow tiddler
- There are plugintiddlers and subtiddlerfields operators as well, to access shadow tiddlers in a plugin.
My simple discovery;
A tiddler containing subtiddlers need not be a plugin, it can be a regular tiddler (containing the subtiddlers) ie not have plugin-type=plugin
(if you change this field back it again becomes a plugin).
- The above widgets and operators can still work against such a tiddler.
- The tiddlers in such a “package” are not accessible as shadows, but they are via the above operators, as subtiddlers. Note if the original plugin is in the wiki they will still be shadows due to that (needs research)
- Another way to generate a tiddler containing subtiddlers is to import or drop some tiddlers on your wiki, rename $:/import and delete its fields (especially plugin-type)
- You can Import all packed tiddlers as “tiddlers”, as follows, note it will replace the original package tiddler, with a list of imported tiddlers as does the $:/Import process.
<$button message=tm-perform-import param="packagetitle">
Import packagetitle
</$button>
Why is this interesting?
- Its a way to pack tiddlers into single tiddler for access from your code, to the field level if needed.
- Including without turning them into tiddlers.
- Its another form of data tiddler
- You can clone or rename it to $:/Import and set plugin-type to import, to its contents.
- You can clone or rename it set plugin-type=plugin to access its contents as shadow tiddlers.
Questions arising;
- How can we save / pack a filtered list of tiddlers into a new package tiddler, with or without plugin-type set
- How can we extract a single tiddler from such a package without making it a plugin first?
- I believe the format of subtiddlers is somewhat different to a JSON file of tiddlers, which can also be imported, and raw JSON can be imported using the deserializer option on the browse widget
<$browse deserializer="text/plain"/>
will import it as a tiddler typetext/plain
and not import the tiddlers within.- However I can not access its subtiddlers or perform and import from that tiddler
- It uses a different format.