projectdoc Toolbox

Transcludes content from a document marked with the content marker macro and renders it as plain text.

The Transclusion To Text Macro includes content from another page at render time and renders it as plain text. Transclusion supports single sourcing.

Since not every environment permits the transclusion of content as plain text due to security considerations, this macro is disabled by default.

This is similar to the Transclusion Macro. The Transclusion Macro, in contrast to this macro, renders the content with target format HTML. Therefore use the Transclusion To Text Macro if you need to process the transcluded content (e.g. with the Body Graph Macro).

The content to be transcluded has to be marked as a section (Section Macro) or region content (Content Marker Macro).

 

Transclusion only works with plain Confluence pages since version 1.11 of the projectdoc Toolbox.

Before that version only transclusion from projectdoc documents was defined. Creating a projectdoc document is simple: add the Document Properties Marker Macro. No special properties required.

The body provides space for replacements of the form "placeholder=replacement", each on its own line. Specify a placeholder like this ${placeholderName}.

Properties

The macro provides the following parameters.

Document

The Confluence page from which to transclude content. As this field is mandatory you have to enter the page from which to transclude content. In the case of transcluding content from the current page combined with a theme like the ones provided by Brikit Theme Press for Confluence you can use @self as the name of the page to indicate that the content shall be transcluded from the page that uses this layout.

Identifiers

The identifiers of marked content or sections to include.

Usually only one identifier is used to include one content, but it need not to be only one.

The identifier of a section defaults to its title.

To control the rendering you have the following options (available since version 1.8.0):

OptionDescriptionExample
-Suppress the rendering of the section title.-Description
!Suppress the section.!Description
 

Please not that complex section containment scenarios and suppressions are only supported in Confluence greater or equal to 5.8.

 

Here are some more examples on how to use identifiers to transclude sections.

IdentifiersDescription
-DescriptionRender every section, but suppress the heading of the description section.
-Description, !*Render only the description section, but without its heading.

Since version 1.17 it is possible to positively include all markers. This is necessary in case titles for selected sections need to be suppressed, but should not indicate that this is a selection.

 

Here are some more examples on how to use identifiers to transclude sections.

IdentifiersDescription
-Description, *, !ReferencesRender every section, but the references section and suppress the heading of the description section.

Tags

The tags of marked content or sections to include. Multiple elements are added in the order they appear in their document.

Force Show

If checked then content that is hidden in its original location is shown.

This effectively overrides the hide parameter of a Section Macro or Content Marker Macro.

Render Reference Box

If checked, a box that marks the transcluded text is rendered with a link to the part in the document (if the transcluded part is uniquely identifiable).

Here is an example of transcluded content from an example page named "A Document":

Example of transcluded content with box.

If you click on the name you jump to the document of the transcluded content.

A transclusion box is a handle, typically only available to users who actually have write access to a page, to quickly jump to the page from which content is transcluded.


The rendering can be controlled via space property render-transclusion-box.

The following values are valid:

only-with-edit-permission

The reference box is only rendered, if the user has edit permission. That is the user is an other and benefits from the clue of transcluded content.

never
The reference box is never rendered. This may proof useful for authors that want to check the appearance without boxes.

Live Templates with Impersonator

 

The impersonator box has edges on the upper left and lower right corner.

Impersonate

The Impersonate Feature allows to define a template that is rendered in the context of the transcluding document.

If checked the transcluding document is used to render the content of the transcluded document.

See Impersonator - using Live Templates for a tip on using this feature.

Apply Document Properties

If Apply Document Properties is checked properties of the document and space are applied as placeholders.

Missing Content Message

If unchecked, no message will be rendered, if no content is to be transcluded.

Usually maintainers of the documentation site require to take notice of missing transclusions. So if this option is checked (per default), a warning message will be rendered on missing content.

Example message on missing content 'Content2'.

Remove Template Buttons

If checked template buttons are not transcluded.

This makes it easy to remove buttons from content. Otherwise the button would create new pages as children to the transcluding page.

No Cache

If checked the macro will not use the page fragment cache to calculate the transcluded page fragment.

This does only apply if the space is using the transclusion cache. Otherwise the state of the checkbox has no effect.

 

This parameter is available since version 1.9.0.

If the macro uses placeholders, caching will automatically switched off.

Wrapping Element

Provide the name of an element to wrap around the transcluded content. Only text and digits are allowed. Should be a valid HTML element name, but is not enforced.

Since 4.6.1

 

Available since version 4.6.1.

CSS Classes

CSS classes for the wrapping element. Only applied if a wrapping element is specified.

Since 4.6.1

 

Available since version 4.6.1.

Identifier

The identifier is rendered with the encosing HTML element.

It is also useful to uniquely identify the macro in a page.

 

This parameter is available since version 1.12.0.

Identifier Classes

Apply identifier classes to render this macro as part of a group.

This identifier is used for Remote Control and Context Controlled Macros. Multiple macros on a page may have only one unique Identifier, but may share common identifier classes.

Context controlled

When checked configures parameters via document and space properties.

For more information please refer to Context Controlled Macros.

Remote Controls

List of controls to pass to transcluded contexts. Controls are separated by ampersand ('&').

Since 4.5

 

Available since version 4.5 of the projectdoc Toolbox.

This allows to control the rendering of remote controllable macros by sending controls. For more information please refer to Remote Control.

 

To alter the rendering of a remote control macro identified by id 'docs', use the following controls:

docs:select=Name,Type&docs:render-mode=definition

The tip Remote Controls for Transclusion provides a short introduction in how to use this feature.

Macro Body

Specify the replacements in the macro's body.

The transcluded content may specify placeholders in the form ${placeholder-name}.

Placeholder/replacement pairs identify the placeholder to be replaced by its name and content for the replacement of the placeholder.

Before version 4.8 the body of the macro only accepts plain text. Therefore only plain text replacements were supported.

Since version 4.8 the body accepts rich text. Users may specify replacements in both forms.

Plain Text Replacements

Switch the body to preformatted and specify key/value pairs in plain text form.

Here is a sample key/value list in text form.

placeholder-name=Replacement 1
Another Placeholder Name=Replacement Text Two

Everything before the first equal sign ('=') is considered to be the key for the placeholder, everthing after the equal sign up to the end of the line is the value.

 

This is an example for placeholder replacements in the body:

product-name=projectdoc Toolbox
product-version=2.0

And this is an example of a fragment that defines the placeholders:

There current version of ${product-name} is ${product-version}.

Rich Text Replacements

To replace a placeholder with an HTML element, add a table with two columns.

Only lines with table data are parsed. The table header is purely to guide authors and may not be specified at all.

Details

Remote Controlled Documents

 

Remote Controlled Documents are available since version 2.0 of the projectdoc Toolbox.

Remote Controlled Documents allow to control the content at request time. A HTTP  request may override parameters of the transclusion macro. A request parameter addresses a transclusion macro by its identifier. After the identifier the name of the parameter is appended, separated by a colon.

Override Parameters

 

Assume that the identifier of the transclusion macro is set to 'my', the following call will override the document and ids parameter on the page 'MyPage' in space 'MYS'.

confluence/display/MYS/MyPage?my:document=b2&my:ids=Description

Also the body can be overridden to replace placeholders in the transcluded fragments.

Override Body

 
body=Placeholder1%3DMyValue1\nPlaceholderX%3ValueB

The list of parameters allowed to override:

  • document
  • ids
  • tags
  • select
  • taget-heading-level (yes, the 'r' is missing!)
  • render-document-name-as-heading
  • apply-document-properties
  • render-error-on-no-content
  • remove-template-buttons

Since 3.1

 

Since version 3.1 these parameters can also be controlled by the context of the macro.

Search Transcluding Pages

To search for pages that transclude information from a given document, use the following search syntax:

macroName:projectdoc-transclusion-macro* AND ("{Title of transcluded page}")

This will return all pages that are using the transclusion macro and have the title on their page content.

 

Using How to search for macros and macro parameters in Confluence 4 would be better, but it did not work out of the box.

If you are using documentation modules, the pages transcluding the module will be displayed automatically.

Transcluding Content with identical Titles

If you have a document with identical titles, it is still possible to transclude the individual sections. Confluence ensures that each heading on a page is unique. This is required by the HTML 5 standard. projectdoc use this service to also make sections unique. Therefore a title that occurs a second time on the same page is suffixed with '.1'. The next with '.2', '.3', and so on.

Here is the page with two sections titled 'Content'.

Here is the macro editor selecting the content of the second section titled 'Content' by selecting on 'Content.1':

Activate Macro

To activate the macro an administrator needs to go to the Add-on page.

Here activate the macros for use by Confluence users:

  • projectdoc-transclusion-to-text-macro - used as a standard macro
  • projectdoc-transclusion-to-text-macro-curly - used in context where Confluence Wiki Markup is required

Confluence Wiki Markup

 

In both use cases the name of the macro projectdoc-transclusion-to-text-macro is used.

Related macros

Name Short Description Notes
Transcludes content from a document marked with the content marker macro.
To use for transclusion that needs not to be rendered as plain text.
Marks a piece of content within a document. This content can be referenced for transclusion.
Allows to mark a content with an identifier or tags.
Renders a section, if the body is not empty. Supports authors to create content, clutter-free rendering without empty sections. Allows to transclude the content.
Similar to the content marker macro, but also allows to set a heading.
Renders transcluded content fetched from documents of a result set.
To transclude from documents selected by a query.

Resources

Transclusion Macros

A list of macros supporting transclusion or embedding of contents provided by Atlassian:

Related Topics

Content Reuse
The projectdoc Toolbox provides a number of features to help teams to reuse content. Content can be transcluded individually or in form of a multitransclude. Authors can even transclude content from multiple documents in the wiki, effectively combining transclusion with automatic lists.
Transclusion
Tools to provide or consume content to support reuse.
Fragments Cache for Transclusions
Information on how to use the fragments cache.
Impersonator - using Live Templates
A short introduction using the impersonator feature of the projectdoc Toolbox. In this example we examine what to do to reuse a layout defined in another document.