|
[
Permalink
| « Hide
]
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.
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...
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
|
||||||||||||||||||||||||||||||||||||||||||