Variables for Blueprints

The projectdoc Toolbox provides an interface for template authors to replace placeholders with space and context properties.

Audience
Expected Duration
30 min
Type

When a page author creates a page with a blueprint wizard, the template author may want to speed up page creation by providing some useful default values for the wizard or the generated page. The default texts may rely on information from the current context (such as the current date or user creating the page) or the space the page is part of (such as the name or the version of the product).

The projectdoc Toolbox supports to replace these placeholders.

Summary

projectdoc allows to replace placeholders at build time. Either before the blueprint wizard's form is rendered or after the author submitted the form. The replacement of placeholders is conducted at creation time of the page.

Template authors may use macros of the projectdoc Toolbox (that is Display Space Property Macro, the Display Space Attribute Macro, or the Display Document Property Macro or one of its cousins) to render space and document properties that are resolved at request time.

Replace in Wizard

Template authors may need to prefill the input fields of a wizard's form. For text fragments containing placeholders the projectdoc Toolbox provides a service to replace those placeholders with context or space property values.

The service is located at /plugins/servlet/projectdoc/toolbox/resolve. It provides the following parameters

ParameterDescription
templateThe string template with placeholders to replace.
spaceKeyThe key to the space whose properties are used to replace placeholders.
pageIdThe identifier of the page (long) or a page reference of the format spaceKey:pageTitle (where the space key is optional and defaults to the spaceKey parameter of the service.

The following context information can be accessed by specifying a placeholder in the template string and passing it to the service.

currentDate
The current date, formatted by the Confluence date formatter.
currentTime
The current time, formatted by the Confluence time formatter.
currentDateToken
The current date, formatted with yyyy-MM-dd.
currentUserId
The login name of the user creating the page.
currentUser
The full name of the user creating the page.
currentUserEmail
The email address of the user creating the page.

To access space properties, simply specify the name of the property you need to be resolved.

On success (code 200) the template's placeholders are replaced or removed, if no valid for them is found.

If a placeholder cannot be replaced, it is removed. The template author may define a scope by curly brackets. If at least one of the placeholder within such a scope is not replaced, the whole scope is not rendered.

Replace after Submit

To replace placeholders entered by the page author the template author may specify the fields to filter in the Soy template. The names of the fields are listed in a hidden field with the name projectdoc-replace-fields-request.

To activate the replacement process, the Context Provider is required to inherit from ProjectDocContextProvider. Please refer to add-on sources on Bitbucket for details.

Current Values in the Page

The first two examples set values to the page at creation time. It is also possible to reference space and document properties and have them replaced at request time.

Use the Display Space Property Macro, the Display Space Attribute Macro, or the Display Document Property Macro (or one of its cousins) to reference space properties, space attributes, or document properties.

Resources

More information for template authors.

Blueprint Properties
Lists the configuration options for template authors to control page creation.
Context Provider
The main purpose of content providers is to add additional context entries for the blueprints provided by an add-on. projectdoc defines a number of context providers to be used by add-on developers.
Doctypes Introduction
A gentle introduction to page blueprints provided by doctype add-ons. The page blueprints are grouped semantically to make it easier for users to build a conceptual mind map for them.
Tour for Template Authors
This is a tour through the documentation for users that want to design their own set of templates or just want to create one or two templates.
Translate Placeholders in Short Description
The short description, stored in the blueprint context may contain placeholders that are translated to their final values.
Page Wizard Placeholder
The pages wizards provide placeholder to make page creation easier.