Currently, when defining snippet, there are only three property types - text (string), checkbox and dropdown. Right? What if… there will be for example yaml configuration for creating large logic snippets, like promoboxes, etc.
If you wish to create a simple boxes (for ex. with same fields) you currently need to create as many snippets as boxes you need. right? so, this way is realy repeatable and when you will to prepare some content for client, wrong use can damage output.
example:
you have container and inside are boxes… in Static Pages you need to create a static div container and there put some snippets with boxes… client are not aware of that and removes container… layout was broken…
solution:
large repeatable contents (tabs, blocks, etc.) can be managed same way as repeatable form field, then, when you add funcionality to accept yaml form configuration for this kind of property type, this will be helfpull.
Then define your blocks in the YAML file. For example,
hero_block:
name: Hero
description: Full width image with title and subtitle overlayed
fields:
# Define your fields here
content_image_block:
name: Content and image
description: Rich editor field with responsive image on the right
fields:
# Define fields for this block here
Then, back in your blocks’ layout file. Loop over the repeater and render the HTML depending on the block’s identifier…
I like to stick each block’s HTML in a partial, passing the block content to it, to keep the layout file cleaner
{% for block in blocks %}
{% if block._group == "hero_block" %}
{% partial 'blocks/hero_block.htm' block=block %}
{% endif %}
{% if block._group == "content_image_block" %}
{% partial 'blocks/content_image_block.htm' block=block %}
{% endif %}
{% endfor %}