I think you can do it
without Javascript but solely with
Velocity (Polarion uses version 1.4 of it btw) which makes it less complicated.
Instead of a button you could create a link (special ones which were designed for wikipages, see bottom of the post for more) which could execute the "escaped script" as you have called it. The link contains the URL to the same Wikipage in which you have the other, non escaped script part
+ a parameter (like for example a work item ID). In an if condition, you can then check if a parameter was passed or not. If yes, the escaped part is executed. If not (which is the inital status when you open the part), only the unescaped part is executed. I did that once at it worked fine.
Check the [url=help]detailed Syntax Help[/url] which you can find when editing Wiki Pages.
There you can find both chapters
Links and
Parameters which demonstrate how to define parameters and how you can inlcude them in a link, in those special links with the square brackets, hence [ ].
A code segment for loading a parameter plus an if condition that checks if the parameter has value (hence it checks if you clicked on the link) can llok like this. Note that you do not have to define the variable $request, it is more or less already "built in" like $trackerService:
Code: Select all
{parameter:version|type=string}
{parameter-form}
##get the work Item with the Input ID
#set ($parameter= "")
#set ($parameter = $request.getParameter("myParamater"))
## Do further "un-escaped code"
## check if parameter is empty
#if($parameter == "")
## Do something that should not appear when the "escaped code" is executed
#else
## execute the "escaped code"
#end
You could also pack this if-condition in a
method, which allows even more flexibility.
