macros.html.twig 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. {% macro settings_details_element(title, summary, id, details_content, context, details_ids) %}
  2. {% if details_ids is null %}
  3. {% set details_ids = [id] %}
  4. {% endif %}
  5. <details class="section-settings-details" {{ open_details(context.open_details_query, details_ids) }} id={{ id }}>
  6. <summary>
  7. <strong class="section-settings-details-title">
  8. {{ title | trans }}
  9. </strong>
  10. <em>
  11. {{ summary | trans }}
  12. </em>
  13. </summary>
  14. {% if details_content is instanceof('Twig\\Markup') %}
  15. {{ details_content }}
  16. {% else %}
  17. {{ form(details_content) }}
  18. {% endif %}
  19. </details>
  20. {% endmacro settings_details_element %}
  21. {% macro settings_details_container(title, summary, container_id, tabs, context) %}
  22. {% set children_ids = [container_id] %}
  23. {% set details_content %}
  24. <nav class='section-settings-nav'>
  25. <ul>
  26. {% for tab in tabs %}
  27. <hr>
  28. <li>
  29. {% set content %}
  30. {% if tab['controller'] is defined %}
  31. {% include tab['controller']['_template'] with tab['controller'] only %}
  32. {% else %}
  33. {{ form(tab['form']) }}
  34. {% endif %}
  35. {% endset %}
  36. {{ _self.settings_details_element(tab['title'], tab['desc'], tab['id'] ~ '-details', content, context) }}
  37. {% set children_ids = children_ids|merge([tab['id'] ~ '-details']) %}
  38. </li>
  39. {% endfor %}
  40. </ul>
  41. </nav>
  42. {% endset %}
  43. {{ _self.settings_details_element(title, summary, container_id, details_content, context, children_ids) }}
  44. {% endmacro settings_details_container %}