Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Status | ||||
---|---|---|---|---|
|
Sometimes, it is required to dynamically allocate the macro content for template purposes or other
...
reasons (e.g., when documenting many similar things, like micro services).
...
To achieve this, it
...
is necessary
...
to make the macros' parameters externally available. In the following
...
section, we present
...
examples that help
...
you to create these templates.
Use Case: Create Pages from a Template for Micro Services with 'Include Bitbucket Server for Confluence' Macros
Every micro service page should contain 3 'Include Bitbucket Server for Confluence' macros:
Image AddedSteps
1) Create a Page Template
Refer to the following guide.
2) Create New User Macros
1) In the administration section go to the user macro section
2) Create new user macro
3) Define name and title for the user macro
4) Fill in the code in the mandatory template field. The template content depends on what you like to include. The following examples show some possibilities. It is important to define the required parameters so that you can access them via the user macro.
4.a Define a template to include a
...
Bitbucket Server file path with User Macro Template Syntax
Code Block |
---|
## @param repoSlug|type=string|required=true
## @param branchId|type=string|required=true
## @param projectKey|type=string|required=true
## @param filepath|type=string|required=true
## @param showLineNumbers|type=boolean|required=false|default=true
## @param lineStart|type=int|required=false
## @param progLang|type=string|required=true
<ac:structured-macro ac:name="stashincludebyfilepath">
<ac:parameter ac:name="repoSlug">$paramrepoSlug</ac:parameter>
<ac:parameter ac:name="branchId">$parambranchId</ac:parameter>
<ac:parameter ac:name="projectKey">$paramprojectKey</ac:parameter>
<ac:parameter ac:name="filepath">$paramfilepath</ac:parameter>
<ac:parameter ac:name="showLineNumbers">$paramshowLineNumbers</ac:parameter>
<ac:parameter ac:name="lineStart">$paramlineStart</ac:parameter>
<ac:parameter ac:name="progLang">$paramprogLang</ac:parameter>
</ac:structured-macro> |
Then, go to your template. The following definition of Wiki markup makes the rendering of the Include macro possible :
Image AddedTry your example with copy/paste:
Code Block |
---|
{include-bss-filepath-wrapper-macro:repoSlug=include4confluence|branchId=refs/heads/master|projectKey=TEST|filepath=test-files/source/groovy.gsh|lineStart=4|progLang=groovy} |
Hint:
Info |
---|
|
This renders the following output:
Image Added4.b Define a template to include a branch list of a Bitbucket Server repository with User Macro Template Syntax
Code Block |
---|
## This is an example macro
## @param repoSlug=Name|type=string|required=true
## @param projectKey=Name|type=string|required=true
<ac:structured-macro ac:name="stashbranches">
<ac:parameter ac:name="repoSlug">$paramrepoSlug</ac:parameter>
<ac:parameter ac:name="projectKey">$paramprojectKey</ac:parameter>
</ac:structured-macro> |
This definition makes it now possible to access the Include for Bitbucket Server Macro parameters via Wiki markup syntax in the User Macro:
Image Removed
Then, go to your template. The following definition of Wiki markup makes the rendering of the Include macro possible :
Image AddedTry your example with copy/paste:
Code Block |
---|
{include-bss-branches-wrapper-macro:repoSlug=include4confluence|projectKey=TEST} |
This renders the following output:
Image Modified4.
...
c Define a Template to include the latest Commits from a Bitbucket Server project with User Macro Template Syntax
Code Block |
---|
## @param repoSlug:title=Repo Slug|required=true
## @param branchId:title=Branch Id|required=true
## @param projectKey:title=Project Key|required=true
<ac:structured-macro ac:name="stashcommits">
<ac:parameter ac:name="repoSlug">$paramrepoSlug</ac:parameter>
<ac:parameter ac:name="branchId">$parambranchId</ac:parameter>
<ac:parameter ac:name="projectKey">$paramprojectKey</ac:parameter>
</ac:structured-macro> |
Add user macro with wiki markup on a page:
Then, go to your template. The following definition of Wiki markup makes the rendering of the Include macro possible :
Image AddedTry your example with copy/paste:
Code Block |
---|
{include-bss-commits-wrapper-macro:repoSlug=include4confluence|branchId=refs/heads/master|projectKey=TEST} |
This renders the following output:
...
Panel | ||||
---|---|---|---|---|
| ||||
|