You are here

gridstack-box.html.twig in GridStack 8

Same filename and directory in other branches
  1. 8.2 templates/gridstack-box.html.twig

Default theme implementation for the individual GridStack box/item template.

Available variables:

  • attributes: An array of attributes to apply to the element.
  • item.box: A renderable array of the main image/background, or empty if CSS background image is preferred.
  • item.caption: A renderable array containing caption fields if provided:
    • title: The individual box title.
    • link: The box links or buttons.
    • data: any possible field for more complex data if crazy enough.
  • settings: An array containing the given settings.

File

templates/gridstack-box.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation for the individual GridStack box/item template.
  5. *
  6. * Available variables:
  7. * - attributes: An array of attributes to apply to the element.
  8. * - item.box: A renderable array of the main image/background, or empty if
  9. * CSS background image is preferred.
  10. * - item.caption: A renderable array containing caption fields if provided:
  11. * - title: The individual box title.
  12. * - link: The box links or buttons.
  13. * - data: any possible field for more complex data if crazy enough.
  14. * - settings: An array containing the given settings.
  15. *
  16. * @see template_preprocess_gridstack_box()
  17. */
  18. #}
  19. {%
  20. set classes = [
  21. 'gridstack__box',
  22. 'box',
  23. 'box--' ~ (delta + 1),
  24. settings.nested_id ? 'box--' ~ settings.nested_id,
  25. settings.layout ? 'box--caption--' ~ settings.layout|clean_class,
  26. settings.class ? settings.class,
  27. settings.background ? 'box--background',
  28. settings.type ? 'box--' ~ settings.type|clean_class,
  29. item.box is empty ? 'box--empty',
  30. settings.attributes.class ? settings.attributes.class|join(' '),
  31. not settings.use_framework ? 'grid-stack-item',
  32. ]
  33. %}
  34. {%
  35. set content_classes = [
  36. 'box__content',
  37. ]
  38. %}
  39. <{{ wrapper }}{{ attributes.addClass(classes) }}>
  40. {% if not settings.use_framework %}<div{{ content_attributes.addClass(content_classes) }}>{% endif %}
  41. {{ item.box }}
  42. {% if item.caption %}
  43. <div class="box__caption">
  44. {% if item.caption.title %}
  45. <h2 class="box__title">{{ item.caption.title }}</h2>
  46. {% endif %}
  47. {% if item.caption.data or item.caption.alt %}
  48. <div class="box__description">
  49. {{ item.caption.data }}
  50. {{ item.caption.alt }}
  51. </div>
  52. {% endif %}
  53. {% if item.caption.link %}
  54. <div class="box__link">{{ item.caption.link }}</div>
  55. {% endif %}
  56. </div>
  57. {% endif %}
  58. {% if not settings.use_framework %}</div>{% endif %}
  59. </{{ wrapper }}>