Getting The Content of Custom Widget in a Variable

The only way to access the result of a widget, before you display something is to use the wikify widget which is discouraged.

  • When I say display something, I am talking about the final render to html step that TiddlyWiki does.

As general rule now I say to myself “a widget, custom or otherwise is where information goes to be displayed”. Think of widgets as being a container which may even contain other widgets, even buttons and other interactions but that each widget is a container and is not available as a variable, it generates output.

  • Consider a list or button widget, they produce a result, they display a list or a button.
  • Inside the list you can access a variable such as the current tiddler, but outside you can’t access the list widget as a variable (without wikification).
    • Since list widgets iterate filters, keep this as filter, or as a function or a procedure that need not be wikified.

This points one to use functions or variables (let set vars) and only a subset of procedures and macros, that do not need wikification.

  • In your csv data example it is literals, so placed inside a procedure, it can be made use of without wikification.
  • The best thing about functions, or triple curly braces and the new back tick attributes is they are evaluated “in place” so their wikification is unnecessary.
    • That I mean here by evaluation is to retrieve variables, fields, and tiddler content and evaluate any filter operators, to produce an output.
    • functions are a way of expressing a filter as a variable, it returns the first value, to return more than one value, join[] them together, and if necessary enlist them later.

To use the content of a widget call in a widget definition, you need to use the $slot="ts-raw" but this is a widget and has the above limitations. I asked for this to be made available as a variable.

Finaly, if you are trying to generate a complex output you want to use as input in another place, the transclusion process can also be used.

  • For example your above csv data could be in its own tiddler and transcluded, rather than a widget.
  • I still need to work on a detailed position on transclusions as a form of wikification.
    • In someways when you transclude you are saying wikify everything within that transclusion NOW, and return that result. Transclusions can be given as an attreibute to a macro or widget.