TiddlyWiki is as powerful and flexible as it is because it allows you to slice up content into small pieces – often, but not always, Tiddlers – and reuse them in many different contexts. But how do we actually go about reusing tiddlers or other pieces of wikitext in different contexts? So far we've seen that we can filter tiddlers into lists, but that's about as far as we've gotten.
Ultimately, what we need is a way to weave together wikitext from different sources into a single document. That process of including wikitext from other sources in a document is called transclusion, and is the subject of this chapter.
First, we'll talk about three ways we can transclude content: variables, procedures, and field transclusions. Then we'll go over some more advanced ways to use field transclusions, as well as how transclusions of all kinds integrate with filters. Finally, we'll explore how you can include wikitext only if certain conditions are true, not every time.
This chapter is the core of the book and the core of TiddlyWiki. The features we discuss here, in one form or another, power most of the tools in TiddlyWiki that allow you to avoid repetitive work and customize your wiki to your liking. If you fully understand these three things and the way they integrate with the rest of TiddlyWiki, along with filters, you'll be able to accomplish almost anything in TiddlyWiki.
While the concepts in this chapter are, for the most part, not intrinsically complicated, there are a lot of details to internalize, and the way TiddlyWiki does things may be different enough from the way you're used to other apps doing things to be a bit confusing at first. So this chapter is packed with exercises, and it will likely take you somewhat longer than the previous chapters to work through.
In this chapter
- Variables – Variables let you assign a name to an arbitrary value, then use the name in place of the value in multiple places within your wikitext.
- Using Variables as Attributes – You can use the value of a variable as the value of an HTML or widget attribute, although there are additional complications.
- Procedures – Procedures extend the concept of variables by allowing portions of the value to change each time the procedure is referenced.
- The Finer Points of Procedures – Procedures come in many forms.
- Field Transclusions – Field transclusions work much like variable transclusions, but their value is tied to a field of a tiddler.
- Templates and the Current Tiddler – Combining transclusions and manipulation of TiddlyWiki's
currentTiddler
variable gives us templates, tiddlers that control the way other tiddlers are displayed. - Filters and Transclusions – TiddlyWiki can transclude the output of a filter, or transclude a variable or field into a filter.
- Parameterizing Field Transclusions – Tiddler fields can have parameters, just like procedures can have parameters.
- Conditional Expressions – Conditional expressions make it easy to show part of a tiddler's wikitext only under certain conditions.
- Summary of Transclusion Syntax – Review all the syntax used for reusing and relating content in TiddlyWiki.