@COPY

Copies the content that follows this action, to reuse it elsewhere in the document with @PASTE.

Should be followed by some content, then a @ENDCOPY action to mark the end of the copied content.

Think of the common copy/paste pattern. DocuMold is essentially doing that when generating a document.

Usage

<# @COPY("name") #>

Parameters

name

(Required) The name to use to refer to this copied content with @PASTE. Must be a text (with quotes \"). Cannot be a variable.

Examples

Example With these variables Result

<# @COPY(“example”) #>
Some text here
One more line
<# @ENDCOPY #>
But then!
<# @PASTE(“example”) #>

(None)

Some text here
One more line
But then!
Some text here
One more line

<# @COPY(“example”) #>
Some text here
<# @ENDCOPY #>

(None)

Some text here

<# @COPY(“example”) #>
Some text here
A command: <# UPPER(client_name) #>
<# @ENDCOPY #>
But then!
<# @PASTE(“example”) #>

client_name is "Anna Logwatch"

Some text here
A command: ANNA LOGWATCH
But then!
Some text here
A command: ANNA LOGWATCH

<# @IF(country = “Canada”) #>
For Canadians:
<# @COPY(“first_part”) #>
Some text here
One more line
<# @ENDCOPY #>
<# @ELSE #>
For non-Canadians:
<# @PASTE(“first_part”) #>
<# @ENDIF #>

country is "Belgium"

For non-Canadians:
Some text here
One more line

Before: <# @PASTE(“ex”) #>
<# @COPY(“ex”) #>Some text<# @ENDCOPY #>
Once: <# @PASTE(“ex”) #>
Again: <# @PASTE(“ex”) #>

(None)

Before: Some text
Some text
Once: Some text
Again: Some text

More information

The @COPY and @ENDCOPY actions will be removed from the document, but the content in between will remain where it initially was.

@COPY is meant to be used with the @PASTE action, which also receives a “name”. The @PASTE action will be replaced by the content of the @COPY (or @CUT) that has the same name. @PASTE can be used before or after the @COPY (or @CUT).

Multiple @PASTE actions can be used with the same @COPY.

The main use for this action is if you have a section of content that you use in multiple places in the document, possibly within multiple @IF. Place the content normally in the first desired location, wrap it with the @COPY and @ENDCOPY actions, then every other places, use @PASTE to reuse the content.

The content of a @COPY action is always copied for use elsewhere in the document (with @PASTE), even when the @COPY is removed by a @IF action.

The name of the @COPY must be unique within the document, including with @CUT actions.

See also

  • TODO: @PASTE
  • TODO: @ENDCOPY
  • TODO: @CUT