Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Document Properties Marker
overridefalse
Short DescriptionThe projectdoc Toolbox provides an interface for template authors to replace placeholders with space and context properties. 
Doctypetopichide
NameVariables for Blueprints 
Parent
Parent Property
propertyParent
property-nameName
 
Audience
Name List
doctyperole
render-no-hits-as-blanktrue
render-list-as-comma-separated-valuestrue
namesTemplate Author, Documentation Architect
propertyAudience
empty-as-nonefalse
 
Level of Experience
Name List
doctypeexperience-level
render-no-hits-as-blanktrue
propertyLevel of Experience
 
Expected Duration30 min 
Subject
Name List
doctypesubject
propertySubject
 
Categories
Name List
doctypecategory
propertyCategories
 
Tags
Tag List
propertyTags
 
Iteration
Iteration
valuefilled
hide
Type
Name List
doctypetopic-type
render-no-hits-as-blanktrue
namesTutorial
propertyType
empty-as-nonefalse
 
Sponsors
Name List
doctypestakeholder
render-no-hits-as-blanktrue
propertySponsors
 
Sort Keyhide
Section
show-titlefalse
titleDescription

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 PDAC1 supports to replace these placeholders.

Note Box

This feature is available since version 1.11 of the projectdoc Toolbox.

The API is ot considered stable until version 2.0 of the projectdoc Toolbox. Incompatible changes may be rolled out on any minor change. Usually they will be reported in the release notes.

Section
titleSummary

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.

Section
titleReplace 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.

Definition List
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.
Example Box
titleString Template with Placeholders: Context Properties
Code Block
New report by ${currentUser} on ${currentDate}

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

Example Box
titleString Template with Placeholders: Space Properties
Code Block
New Release V${Version} for ${Product Name}

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

Example Box
titleService Call from JavaScript

The following snippet is an example on how to access the service and replace the content of an input field of a wizard's form.

Code Block
languagejs
wizard.on('pre-render.page1Id', function(e, state) {
  var template = "New report by ${currentUser} on ${currentDate}";
  var url = AJS.contextPath()
             + "/plugins/servlet/projectdoc/toolbox/resolve?template="
             + template + "&spaceKey=" + state.wizardData.spaceKey;
  AJS.$.ajax({
    url: url,
    success: function(data, status) {
                if(status === 'success') {
                    state.soyRenderContext['name'] = data;
                }
            },
    async: false
  });
});

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.

Example Box
titleTemplate with a Scope
Code Block
languagetext
New report{ (Version ${Version})}

Without the scope the template (with an unresolved version placeholder) would be resolved to New Report (Version ), but with the scope the result is New Report.

Section
titleReplace 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.

Example Box
titleSpecify Fields with Placeholders
Code Block
<input id="projectdoc-replace-fields-request" 
  type="hidden" 
  name="projectdoc-replace-fields-request" 
  value="projectdoc.doctype.common.name, projectdoc.doctype.common.shortDescription">
In this example the fields with name projectdoc.doctype.common.name and projectdoc.doctype.common.shortDescription are filtered and their placeholders, specified by the author, are replaced.

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

Note Box

Typically user's won't reference space properties since they usually know the value they are after better then remembering the name of a space property.

There are placeholders to use in short descriptions and placeholders to use in document names / titles.

These placeholders are prefixed by an ampersand (@) and are not replaced by the service of the previous section. If a template author uses on of them, it will be rendered verbatim in the wizard and will be substituted after the user submits the form.

Section
titleCurrent 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.

Example Box
titleAccess Space Properties at Request Time
Code Block
languagexml
<ac:structured-macro ac:name="projectdoc-space-property-display-macro">
  <ac:parameter ac:name="property-name">project-version</ac:parameter>
</ac:structured-macro>
Section
titlePrerequisites

Section
titleSubordinate Topics
Display Table
doctypetopic
render-no-hits-as-blanktrue
selectName, Short Description
restrict-to-immediate-childrentrue
sort-bySort Key, Name
Section
required-permissionswrite-access
titleNotes

Section
titleReferences

Section
titleResources

More information for template authors.

Tour
render-as-definition-listtrue
replace-title-with-nametrue