Conditional logic for code template

<oXygen/> general issues.
charlesh
Posts: 7

Conditional logic for code template

Mon May 23, 2016 5:58 pm

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>
}
charlesh
Posts: 7

Re: Conditional logic for code template

Mon May 23, 2016 6:01 pm

Sorry, that should be v17.0.

Thanks.
Radu
Posts: 5217

Re: Conditional logic for code template

Mon May 23, 2016 6:27 pm

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/17.1/ug-editor/#topics/dg-default-author-operations.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Return to “Other Issues”

Who is online

Users browsing this forum: No registered users and 0 guests