Reference

Home > Documentation > Syntax > Keywords > Header


Template headers are defined using a header block containing specifiers for three main template behaviours:

  1. The template name.
  2. What kind of multiple output.
  3. The output file path.

 

Definition

header
  is [template_name](argument,list)
  [for_statement]
  return [output_expression]
end

Description

  • header
    Start of the header block.
  • template_name – identifier
    The template is named here using the is keyword and is the identifier for when it is called. The template item name in the project is not the identifier, and although they are generally the same name, they do not have to be identical.
    Parameters are declared within parenthesis. Parenthesis can be omitted if the are no parameters, otherwise empty parenthesis indicate no parameters.
  • for_statement – statement
    If omitted, the output is a single file according to the return expression. If a for statement is specified, the output is multiple according to the return expression (as a rule the return expression makes use of the for iterator).
  • output_expression – string
    The output path. Paths are relative to the location of the Metadrone project file not the executable.
  • end
    Terminates the header block.

Eg, for a single file output writing to the file “the-output.txt”:

header
  is Template1
  return "the-output.txt"
end

The template can be called thus:

call template1

 

For multiple outputs:
(note the use of the for iterator variable in the return expression).

header
  is Template2(connection)
  for table tbl in connection
  return "the-output-" + tbl + ".txt"
end

The template is called and parameter is passed:

call Template2(sources.Source1)