Skip to content

inital work in yaml layout includes

Stuart Fisher requested to merge feature/yaml-include into master

Initial work on yaml include for layouts, closes #7 (closed) Need to deal with variable interpolation

Can be used like so:

name: include
description: Include test
contents:
  - !include partials/2dview.yml

which would include daiquiri/resources/layouts/partials/2dview.yml

The includer searches the local directory first (i.e. where the layouts live), so you can also include local partials for example.

This can now interpolate variables as well:

daiquiri/resources/layouts/partials/2dview.yml:

type: row
default_variables:
  rows: 0
options:
  style: 
    flex: 0 0 calc(100% - (120px * ${rows}))
contents: 
  - type: col
    options: 
      xs: 8
    contents:
      - type: component
        component: twod
        ...

  - type: col
    options: 
      xs: 4
    contents:
      - type: component
        component: twodobjectlist
      - type: component
        component: twodobject
        ...

Then local/resources/layouts/include.yml:

name: include
description: Include test
contents:
  # core daiquiri include
  - !include 
      file: partials/2dview.yml
      variables:
        rows: 1
  - !include partials/single_row.yml

partials can define default_variables which can be overridden by passing variables to the include directive

Thoughts @valentin.valls ?

Edited by Stuart Fisher

Merge request reports

Loading