Usually you create a template for your content insertion command by selecting some content and choosing Custom Content Dialog, then the template, command, and button for the template insertion become available for the currently edited document. For more details on the dialog, see Custom Content Dialog.
(or hitting the button on the custom content toolbar). If you hit OK in theIf you create a template for a custom content " as is", by just taking it from the document, then upon insertion the cursor (and selected content, if there is a selection) will appear within the first element of the template, if any.
You may adjust the custom content template with the Custom Content Dialog's edit box:
The $(cursor) keyword within your template indicates that the cursor and/or wrapped content will go into this position.
For example, the custom content template:
<formalpara> <title>Important note:</title> <para>$(cursor)</para> </formalpara>
applied to the selected portion: some words will produce:
<formalpara> <title>Important note:</title> <para>some words</para> </formalpara>
The $(attribute) keyword within the attribute value will invoke the Attributes Dialog when inserting the custom content.
For example, the template:
<section id="$(attribute)"><title>$(cursor)</title></section>
will invoke the Element Attributes Dialog for the id attribute, and insert the selected content (if any) instead of $(cursor). Note that the following form of the keyword: $(attribute caption="My caption") will change the caption of the Element Attributes Dialog to My caption.
When inserting certain elements (like graphics), it is very convenient to call a file browser. This is possible with the keyword file. For example: $(file caption="My caption" filter="Images (*.gif *.jpg);; All files (*)"). Note that caption provides a caption for the file browser, and filter provides the filters for the file list:
<graphic fileref="$(file caption='Choose Image' filter='Image files (*.gif *.jpg);;All files (*)')"/>
will call a file browser, and insert a graphic with the fileref attribute with the relative file path to the image.
Custom Content can automatically generate unique IDs which consist of the element name and a unique sequence number:
<section id="$(generate-id)"/>
will insert <section id="section_1"> and so on.
It is also possible to specify custom ID format for the Custom Content:
<section id="$(generate-id %t%n)"/>
This example will use timestamp-based ID plus optional sequence number. Format is determined by the percent sign with a single format letter; other symbols are copied as-is.
The default format string (when format string is not specified) is " %q_%n". All possible format sequences are described below.
Local name of the element.
Qualified name (QName) of the element.
Timestamp presented as eight hexadecimal digits.
Mangled current file name.
Current entity name, if any.
Explicit sequence number; at least one digit.
Implicit sequence number which is added only when the ID string generated without this number is not unique. If the %n is not specified in the format string, it is implicitly assumed to be at the end of the format string.
If, for some reason, you want to insert the above-mentioned keywords to your templates but do not want them to be substituted, escape them with the double $ sign. For example, $$(cursor)will appear in your text literally as $(cursor), and will not be replaced.