Page 1 of 1

Conditional logic for code template

Posted: Mon May 23, 2016 5:58 pm
by charlesh
I've created a code template for use when authoring content. It does a nice job of prompting the user for a value, which is then wrapped in a specific element (which has a specific attribute).

I'd like to extend this so that the value of ${selection} is evaluated, and if this is not empty then we simply wrap the current selection. Only if there is no selection would we prompt the user for a value.

Can this be done? I'm using oXygen 17.1

Current Code:

Code: Select all

<keyword otherprops="g.signal.name">${ask('Please provide the signal name.')}</keyword>
Desired (pseudocode):

Code: Select all


if ($selection=="") {
<keyword otherprops="g.signal.name">${ask('Please provide the signal name.')}</keyword>
} else {
<keyword otherprops="g.signal.name">${selection}</keyword>
}

Re: Conditional logic for code template

Posted: Mon May 23, 2016 6:01 pm
by charlesh
Sorry, that should be v17.0.

Thanks.

Re: Conditional logic for code template

Posted: Mon May 23, 2016 6:27 pm
by Radu
Hi Charles,

Sorry but we do not have such possibilities of evaluating conditions when using code templates.
If you are editing in the Author visual editing mode you should consider creating Author actions which can call operations, either implemented in Java or Javascript-based:

https://www.oxygenxml.com/doc/versions/ ... tions.html

Regards,
Radu