(arbor-component
  (meta-data (version "0.1-dev"))
  (decor
    {%- for mech, params in global_mechs.items() %}
    {%- if mech is not none %}
    {%- if mech in global_scaled_mechs %}
    (default (scaled-mechanism (density (mechanism "{{ mech }}" {%- for param in params if param.value is not none %} ("{{ param.name }}" {{ param.value }}){%- endfor %})){%- for param in global_scaled_mechs[mech] %} ("{{ param.name }}" {{ param.scale }}){%- endfor %}))
    {%- else %}
    (default (density (mechanism "{{ mech }}" {%- for param in params %} ("{{ param.name }}" {{ param.value }}){%- endfor %})))
    {%- endif %}
    {%- else %}
    {%- for param in params %}
    (default ({{ param.name }} {{ param.value }}))
    {%- endfor %}
    {%- endif %}
    {%- endfor %}


    {%- for loc, mech_parameters in local_mechs.items() %}{# paint-to-region instead of default #}

    {%- for mech, params in mech_parameters.items() %}
    {%- if mech is not none %}
    {%- if mech in local_scaled_mechs[loc] %}
    (paint {{loc.ref}} (scaled-mechanism (density (mechanism "{{ mech }}" {%- for param in params if param.value is not none %} ("{{ param.name }}" {{ param.value }}){%- endfor %})){%- for param in local_scaled_mechs[loc][mech] %} ("{{ param.name }}" {{ param.scale }}){%- endfor %}))
    {%- else %}
    (paint {{loc.ref}} (density (mechanism "{{ mech }}" {%- for param in params %} ("{{ param.name }}" {{ param.value }}){%- endfor %})))
    {%- endif %}
    {%- else %}
    {%- for param in params %}
    (paint {{loc.ref}} ({{ param.name }} {{ param.value }}))
    {%- endfor %}
    {%- endif %}
    {%- endfor %}

    {%- for synapse_name, mech_params in pprocess_mechs[loc].items() %}
    (place {{loc.ref}} (synapse (mechanism "{{ mech_params.mech }}" {%- for param in mech_params.params %} ("{{ param.name }}" {{ param.value }}){%- endfor %})) "{{ synapse_name }}")
    {%- endfor %}

    {%- endfor %}))
