Template blocks🔗
Template blocks can be used to customize the types and builders generated by cog.
For example, to automatically position panels on the grid whenever they're added to a dashboard.
To achieve that, cog looks for template blocks following a particular naming convention, and renders them.
For types, the following blocks are supported:
object_{{ Package }}_{{ ObjectName }}_custom_unmarshal
: allows the definition of a custom unmarshal function for the object.object_{{ Package }}_{{ ObjectName }}_field_{{ FieldName}}_custom_strict_unmarshal
: allows the definition of a custom — strict — unmarshal logic for a field.variant_{{ VariantName }}_field_unmarshal
: defines how to unmarshal fields of the given variant.object_variant_{{ VariantName }}
: allows the definition of custom methods for all objects implementing the variant{{ VariantName }}
.schema_variant_{{ VariantName }}
: allows the definition of custom code for all schemas implementing the variant{{ VariantName }}
.
For builders, the following blocks are supported:
pre_assignment_{{ BuilderName }}_{{ OptionName }}
: will be rendered within an option, before the assignment.post_assignment_{{ BuilderName }}_{{ OptionName }}
: will be rendered within an option, after the assignment.
For API reference documentation, the following blocks are supported:
api_reference_package_{{ Package }}_extra
: additional content that will be rendered on the documentation page for a package.api_reference_object_{{ Package }}_{{ ObjectName }}_extra
: additional content that will be rendered on the documentation page for an object.api_reference_builder_{{ Package }}_{{ BuilderName }}_extra
: additional content that will be rendered on the documentation page for a builder.
For dynamically generating files, the following block is supported:
* dynamic_files
: in conjunction with the declareFile $filepath $content
template helper.
Note
The variables components of block names are case-sensitive.