2022-01-23 09:44:01 +00:00
caption: transclude
2014-02-12 17:59:28 +00:00
created: 20130824142500000
2022-05-14 12:31:36 +00:00
modified: 20220513114759336
2014-09-10 23:06:19 +00:00
tags: Widgets
2013-08-24 15:45:45 +00:00
title: TranscludeWidget
2014-02-12 17:59:28 +00:00
type: text/vnd.tiddlywiki
2013-08-24 15:45:45 +00:00
! Introduction
The TranscludeWidget dynamically imports content from another tiddler.
! Attributes
|!Attribute |!Description |
2013-10-30 14:30:22 +00:00
|tiddler |The title of the tiddler to transclude (defaults to the current tiddler) |
2013-08-24 15:45:45 +00:00
|field |The field name of the current tiddler (defaults to "text"; if present takes precedence over the index attribute) |
|index |The index of a property in a [[DataTiddler|DataTiddlers]] |
2014-07-17 17:41:20 +00:00
|subtiddler |Optional SubTiddler title when the target tiddler is a [[plugin|Plugins]] (see below) |
2014-02-12 17:59:28 +00:00
|mode |Override the default parsing mode for the transcluded text to "block" or "inline" |
2013-08-24 15:45:45 +00:00
2014-02-12 21:38:37 +00:00
The TranscludeWidget treats any contained content as a fallback if the target of the transclusion is not defined (ie a missing tiddler or a missing field).
2013-08-24 15:45:45 +00:00
2014-02-12 17:59:28 +00:00
! Parsing modes
2022-01-23 09:44:01 +00:00
TiddlyWiki [[parses text in two modes|WikiText Parser Modes]]:
2014-02-12 17:59:28 +00:00
2022-01-23 09:44:01 +00:00
* [[inline mode|Inline Mode WikiText]] recognises character formatting such as emphasis, links
* [[block mode|Block Mode WikiText]] recognises all the ''inline'' formatting, and adds block formatting such as tables, headings and lists
2014-02-12 17:59:28 +00:00
2022-01-23 09:44:01 +00:00
Usually, the mode is determined by whether the transclude widget itself has been parsed in block or inline mode. This can be overridden with the <<.attr mode>> attribute.
2014-02-12 17:59:28 +00:00
For example, consider tiddler "A" with this content:
```
# Item one
#<$transclude tiddler="B"/>
# Item two
```
And a tiddler "B" with this content:
```
# Item one - a
# Item one - b
```
The result will be something like this:
# Item one
# # Item one - a # Item one - b
# Item two
This can be fixed by amending tiddler "A":
```
# Item one
#<$transclude tiddler="B" mode="block"/>
# Item two
```
2022-01-23 09:44:01 +00:00
See also these [[other examples|WikiText parser mode: transclusion examples]].
2014-07-17 17:41:20 +00:00
2018-07-19 16:58:04 +00:00
! ~SubTiddler Access
2014-07-17 17:41:20 +00:00
The transclude widget allows access to the individual tiddlers stored within a [[plugin|Plugins]].
The following example will transclude the core version of the tiddler [[$:/DefaultTiddlers]] even if it has been overridden:
2022-05-14 12:31:36 +00:00
<<wikitext-example-without-html """<$transclude tiddler="$:/core" subtiddler="$:/DefaultTiddlers"/>""">>