References

Fabric language supports code reuse via block references. Note, only data, content and section blocks with names, defined on a root level of the file, can be referenced.

To include a named block defined on the root level into a document, use ref label and base argument:

content <content-provider> "<block-name>" {
  ...
}

data <data-source> "<block-name>" {
  ...
}

section "<block-name>" {
  ...
}


document "foo" {

  <block-type> ref "<block-name>" {
    base = <block-identifier>
    ... 
  }
}
  • <block-type> is either content, data or section.
  • <block-identifier> is a dot-separated identifier for the block to be included. It consists of all labels in the block signature. For example, content.<content-provider>.<block-name> or section.<block-name>. The block name in the identifier shouldn’t be wrapper in double quotes ".

If the ref block is defined on the root level of the file, the block name is required. If it’s within the document block, the block can be anonymous - the name is optional.

Overriding arguments

The ref block definition can include the attribute that would override the attributes provided in the original block. This is helpful if the block’s behaviour needs adjustments per document.