macros.html.twig 1.9 KB

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