I want to define the widgets for all of my columns and layouts in one place.
This code would be in views/macros/columnWidgets.html
{% macro columnWidgets(data, option) %}
{{ apos.area(data.widget, '{{option}}', {
blockLevelControls: true,
widgets: {
'apostrophe-rich-text': {
toolbar: [ 'Styles', 'Bold', 'Italic', 'Blockquote', 'Link', 'Anchor', 'Unlink', 'BulletedList' ],
styles: [
{ name: 'Paragraph', element: 'p' },
{ name: 'Quote / Section Descriptor', element: 'h3' },
{ name: 'Main Heading', element: 'h1',attributes: { 'class': 'main-heading'} }
]
},
'apostrophe-html': {
toolbar: [ 'Styles', 'Bold', 'Italic', 'Link', 'Unlink', 'Anchor', 'Table', 'BulletedList', 'Blockquote', 'Strike', 'Subscript', 'Superscript','Image','slideshow' ],
styles: [
{ name: 'Marker: Yellow', element: 'span', styles: { 'background-color': 'Yellow' } }
]
},
'apostrophe-images': {
minSize: [ 700, 350 ],
aspectRatio: [ 2, 1 ],
size: 'full'
}
}
}) }}
{% endmacro %}
Then in my 4Column Layout Widget I would include something along these lines.
{% import 'macros/columnWidgets.html' as columnwidgets %}
{{ apps.columnWidgets(data,'column1') }}
Sure, we do this all the time in our own projects.
The use of
viewsFolderFallback
is a nice convenience for allowing a shared top-level folder to become a fallback location for template files imported, included, extended, etc. from any module.