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 eithercontent
,data
orsection
.<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>
orsection.<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.
An anonymous
ref
block adopts a name of the referenced block. Since the final name of the block isn’t stated explicitly, unwanted overrides can happen — a block signature must be unique between the blocks defined on the same level.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.