Skip to content

Instantly share code, notes, and snippets.

@jryanconklin
Last active July 24, 2019 16:46
Show Gist options
  • Save jryanconklin/06096041c5a6ffe36f1131a4263c6114 to your computer and use it in GitHub Desktop.
Save jryanconklin/06096041c5a6ffe36f1131a4263c6114 to your computer and use it in GitHub Desktop.
Data Generated Layout Builder
// theme.layouts.yml
theme_8_4:
label: 'Particle 66:33'
path: templates/layout/theme-8-4
template: theme-8-4
category: 'Columns: 66:33'
default_region: main
icon_map:
- [main, main, aside]
regions:
main:
label: Main
grid_size: 8
region_classes: ['layout__region', 'layout__region--main', 'col-sm-8']
aside:
label: Sidebar
grid_size: 4
region_classes: ['layout__region', 'layout__region--aside', 'col-sm-4']
//_layout.twig
// This file is not intended to be used directly. It's referenced as an include by layouts
{%
set classes = [
'layout',
'layout--' ~ layout.id|clean_class,
]
%}
{% if content %}
<div{{ attributes.addClass(classes) }}>
{% for key, value in layout.getRegions %}
{% if content[key] %}
<div {{ region_attributes[region].addClass(value.region_classes) }}>
{{ content[key] }}
</div>
{% endif %}
{% endfor %}
</div>
{% endif %}
// theme-8-4.html.twig
// The following can be used for all registered layouts.
{% @include '@theme/layouts/_layout.twig' %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment