Page 1 of 1

using editor variables in code templates

Posted: Wed Jun 03, 2009 11:41 pm
by matthew.stephens
I would like to write code templates that paste in some of the editor variables that are so useful in validation and transformation scenarios. If something more than ${caret} could be used, the templates become a lot more flexible.

Thanks for making such a great product, by the way!

Matthew Stephens
University of Virginia Library

Re: using editor variables in code templates

Posted: Thu Jun 04, 2009 10:31 am
by sorin_ristache
Hello,

The editor variables are generic placeholders for environment details that are useful in actions applied to XML documents. Do these environment details have a place in the content of the edited XML document? Can you give examples?


Thank you,
Sorin

Re: using editor variables in code templates

Posted: Thu Jun 04, 2009 5:06 pm
by matthew.stephens
Here's an example of how editor variables might be used in an XML document. You might have unique identifiers that you wish to add to a <milestone> element in a file, and you would build a code template to construct the element tag and its accompanying id attribute. If you wanted to prefix each id number with the file's name (to create unique IDs across a collection of files), you would want this in your template:

Code: Select all

<milestone id="${cfn}${caret}" unit="chapter"/>
If that template existed, you could type a key and get the element in your XML file, with the filename already added as part of the attribute value, with the cursor (or caret) in place to add more text to that value.

Given the kinds of markup we do here at UVA Library, that would be a great time-saver.

M.S.

Re: using editor variables in code templates

Posted: Thu Jun 04, 2009 5:44 pm
by sorin_ristache
It sounds like a good candidate for a custom Author action that would be called by pressing a toolbar button in Author mode. Author actions are developed using the Author SDK that is available on the Developer page. The action is developed once, plugged to a document type and used by all the content authors who edit XML documents of the same type.


Regards,
Sorin