{# Dataset -- These macros are designed for handling the layout of content/data from a single result on a view page. The macros combined can be called like so: -------------------------------------------------------------------------------- {%- import "macros/dataset.html" as _dataset -%} {% call _dataset.set('My heading') -%} {{ _dataset.row('Label 1', 'Value 1') }} {{ _dataset.row('Label 1', 'Value 2') }} {% call _dataset.row() -%} {{ _dataset.column('Label 3a', 'Value 3a') }} {{ _dataset.column('Label 3b', 'Value 3b') }} ... {%- endcall %} {% call _dataset.row() -%} {% call _dataset.column() -%} {{ _dataset.label('Label 4') }} {{ _dataset.value('Value 4') }} {%- endcall %} {%- endcall %} {% call _dataset.row() -%} {% call _dataset.column() -%} {% call _dataset.label() -%} Label 5 {%- endcall %} {% call _dataset.value() -%} Value 5 {%- endcall %} {%- endcall %} {%- endcall %} ... {%- endcall %} -------------------------------------------------------------------------------- These macros are designed to be as simple as possible, whilst allowing the flexibility in the templates to write as much or as little code as needed. So for example, if you have a single row of data with only one column needed in the row, you don't need to call the column within the row, you can simply provide the column data to the row macro, and it will build the column for you. This structure flows down in this way all the way from the top (set) macros to the bottom (label/value) macros. #} {# Set -- A macro used to build the container for the dataset. This is the top level macro and is primarily used to wrap multiple rows of data but can be used to display a single row/column of data if required. You can optionally pass a `heading_text` value, which will render a heading at the top of the dataset. This macro can be called like so: -------------------------------------------------------------------------------- {% call _dataset.set('My heading') -%} ... {%- endcall %} -------------------------------------------------------------------------------- As standard you can also pass `class` to apply a custom class style to the containing element. You can also pass any other HTML attribute using keyword arguments and these will be applied to the container. You can use this same approach to pass HTML attributes to the `head` and `heading` macros. -------------------------------------------------------------------------------- {% call _dataset.set( 'My heading', class='some-class', head_attrs={'data-some-attribute': 'Some value'}, heading_attrs={'data-some-attribute': 'Some value'}, **{'data-some-attribute': 'Some value'} ) -%} ... {%- endcall %} -------------------------------------------------------------------------------- #} {% macro set( heading_text=None, class=None, head_attrs=None, heading_attrs=None ) -%} {%- set head_attrs = head_attrs or {} -%} {%- set heading_attrs = heading_attrs or {} -%}