Issue Details (XML | Word | Printable)

Key: VISIB-48
Type: New Feature New Feature
Status: Open Open
Priority: Minor Minor
Assignee: Unassigned
Reporter: James Mortimer
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Confluence Extension: Visibility Plugin

add an {else} clause to all four macros

Created: 05/Jun/08 05:52 PM   Updated: 06/Jun/08 12:09 AM
Component/s: {hide-from}, {hide-if}, {show-if}, {show-to}
Affects Version/s: 1.5
Fix Version/s: None

Time Tracking:
Not Specified


 Description  « Hide
Add an optional {else} tag in any of the four macros.

This is most intuitive for the show-if, but could easily apply to all four. All the text before the {else} tag will be displayed, or hidden, if ALL or ANY (depending on the matches parameter) of the criteria are matched. The text after the {else} tag will be displayed, or hidden, otherwise.

For example:

{show-if:label=application|scope=HELP:|match=all}
You are on an application page in the help space
{else}
You are not on an application page in the help space
{show-if}
{hide-if:label=application}
You are not on an application page
{else}
You are on an application page
{hide-if}
  • essentially, once this tag is edited, one would only need to use the show-if, and never the hide-if. for example, the following are equivalent:
{show-if:label=application}{else}
You are not on an application page
{show-if}
{hide-if:label=application}
You are not on an application page
{hide-if}

this also simplifies blocks of code that used to look like this:

{hide-if:label=application|space=apps|scope=catalog > descendents|matches=all}
You are not on an application page
{hide-if}
{show-if:label=application|space=apps|scope=catalog > descendents|matches=all}
You are on an application page
{show-if}


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
James Mortimer added a comment - 05/Jun/08 05:53 PM
can you please edit the above 'noformat' tags to fix the formatting? I can't edit the issue.

David Peterson added a comment - 05/Jun/08 06:00 PM
Fixed. Are you suggesting a 'real' macro called {else}, or just a special marker? I'm not sure that the former would really work with the current macro parsing system. Plus, you would have to execute the body markup to determine where the {else} was. Using it as a unique marker would be the only way I think...

James Mortimer added a comment - 06/Jun/08 12:09 AM
my 'hack' user macro, 'if', designed to fill in for when show-if doesn't work or we don't have the right version yet, uses it as a simple text delimiter to split the content. Works well so far.
...
#foreach ($clause in $body.split('\{else\}'))
#if($velocityCount==1)#set($clausetrue=$clause)
#end
#if($velocityCount==2)#set($clausefalse=$clause)#end
#end
...

(full source)

## this macro is reserved to create all sorts of conditional behaviour in rendering wiki pages
##
#set($condition=false)
##
## use this macro to do recursive nested conditions???
##macro(evaluateifcondition condition)
## - unary or binary?
## -a split into operator and variable, return unary result (recursive)
## -b split binary into operator and two variables, and return binary result (recursive)
##end
##
#if($parampageexists && $parampageexists.length()>0)
#set($wiki='[')
#set($wiki=$wiki.concat($parampageexists).concat(']'))
#set($result="#render($wiki)")
#if($result.indexOf('error')>0)
#set($condition1=false)
#elseif($result.indexOf('createlink')>0)
#set($condition1=false)
#elseif($result.indexOf('href')>0)
#set($condition1=true)
#else
#set($condition1=false)
#end
#else
#set($condition1=true)
#end
##
#if($paramcancreatepage && $paramcancreatepage.length()>0)
#set($wiki='[')
#set($wiki=$wiki.concat($paramcancreatepage).concat(']'))
#set($result="#render($wiki)")
#if($result.indexOf('error')>0)
#set($condition2=false)
#elseif($result.indexOf('createlink')>0)
#set($condition2=true)
#else
#set($condition2=false)
#end
#else
#set($condition2=true)
#end
##
#if($parampageTitleIs && $parampageTitleIs.length()>0)
#if($content.getRealTitle().toLowerCase() == $parampageTitleIs.toLowerCase())
#set($condition3=true)
#else
#set($condition3=false)
#end
#else
#set($condition3=true)
#end
##
#set($condition=$condition1 && $condition2 && $condition3)
##
#foreach ($clause in $body.split('\{else\}'))
#if($velocityCount==1)#set($clausetrue=$clause)
#end
#if($velocityCount==2)#set($clausefalse=$clause)#end
#end
##
#if($condition)
$!clausetrue
#else
$!clausefalse
#end