Single Source (if-else conditional) plugin
Single Source (if-else conditional) plugin for confluence can be used for following purpose:
- Create single source of content using Single source macro
- Reuse the same content at other places just by using Single source include macro
- While reusing content (text, image,link ...) at other place where some part of content is required to display differently, it could be achieved by providing condition (based on spacekey or space name) and desired content in case condition is true plus desired content in case condition is false
- SpaceKey - SpaceKey is a key representing a Space of Confluence. It is provided during Space creation and generally is also part of Url. http://<yoursite>/display/spacekey/<page> More details
- Space Name - Space name is the name of Space provided during space creation which can also be edited at later stage by going under Space Admin section of Confluence. More details
Create Single Source Content
Use Single Source (if-else) macro to create single source content. Macro interface could be used to provide following parameters
- Single source condition name
- SpaceKey contains and Space Name contains (if spacekey or spacename of current space contains provided string then condition will be true else condition will be false)
- For example macro shown in image, condition will be true if space name contains Syrup else condition will be false.
- Conditional keyword to hide - Keywords (separated by semi colon in case of multiple keywords) provided in this box will be hidden in output
- Show this if condition true - Provided text (separated by semi colon and replacement of each keyword provided in box just above) will be displayed in output if condition is true (respective text corresponding to each keyword in sequence)
- Show this if condition false - Provided text (separated by semi colon and replacement of each keyword provided in box just above) will be displayed in output if condition is false (respective text corresponding to each keyword in sequence)
For example macro shown in image every instance of word TYPE in macro body will be shown as Syrup in output if condition is true otherwise every instance of TYPE will be shown as Tablet i.e if condition is false.
As a real life example we are using sample content related to documentation of Ibugesic plus Syrup and Ibugesic plus tablet where most of the content is same except names and some product specific content. Example content and output is as follows:
We can see in image that single source content is created by using keyword TYPE which is replaced by Syrup if condition is true otherwise TYPE is replaced with Tablet in output. Content specific to one version of manual could also be provided using tags as shown in image shown below
As we can see that there are 2 different tables which are specific to Syrup and Tablet respectively. For such specific content SS_TRUE_ST SS_TRUE_END and SS_FALSE_ST SS_FALSE_END tags could be used as shown in example above. Content between TRUE tags will be displayed only if condition is true and content between FALSE tags will be displayed only if condition is false.
Reuse the Content
Single Source content created using single source(if-else) macro could be reused at any other location by using Single Source(if-else) Include macro.
In case there is Single source content which is mostly the same but having slightly differing more than 2 version, please check our Conditional Multiexcerpt plugin.
Our customers play and important role in making our solution better. Thanks to everyone who provided feedback, suggestions and reported some issues.
Atlassian Marketplace link - Single Source(if-else) plugin