40. formatTextAs

Parameter syntax:

[ filter S ]* '#template(' element_name ',' template_title ')'

This command formats the plain text copied to the clipboard after its element template parameter. For example, if the clipboard contains:

This is the first line.
This is the second line.
This is the third line.

and the element template parameter points to (XHTML example):

<elementTemplate name="PAA.p" selectable="false">
  <p xmlns="http://www.w3.org/1999/xhtml">{$line}</p>
</elementTemplate>

This command will generate and return as a result the following string:

<?xml version="1.0"?>
<ns:clipboard xmlns:ns2="http://www.w3.org/1999/xhtml"
              xmlns:ns="http://www.xmlmind.com/xmleditor/namespace/clipboard">
  <ns2:p>This is the first line.</ns2:p>
  <ns2:p>This is the second line.</ns2:p>
  <ns2:p>This is the third line.</ns2:p>
</ns:clipboard>

This command is useful to create macro-commands. It is also used internally by command pasteAs, which may be seen as a ready-to-use macro-command.

Example:

formatTextAs #template({http://www.w3.org/1999/xhtml}p,PAA.p)

Note how the name of the element is specified using James Clark's notation.

See also command pasteAs.