gridstack.html.twig in GridStack 8.2
Same filename and directory in other branches
Default theme implementation for the GridStack template.
Available variables:
- items: The array of items containing gridstack contents and captions.
- settings: A cherry-picked settings that mostly defines the box HTML or layout, and none of JS settings/options which are defined at data-config.
- attributes: The array of attributes to hold classes, id and config data containing JSON object aka JS settings the GridStack expects. We don't store these JS settings in the normal <head>, but inline within data-config attribute instead.
Important! If you are adding additional contents to any content-related variable here, e.g.: aside, bottom, preface, postscript, etc., be sure to add your own key, normally unique like UUID or module name, to not conflict against, or nullify, module features, or other providers, e.g.: Good: postscript.cta, or postscript.widget (This extends postscript) Bad: postscript = cta (This overrides/ nullifies other postscripts with cta)
Debug: Use Kint: {{ kint(variable) }} Dump all available variables and their contents: {{ dump() }} Dump only the available variable keys: {{ dump(_context|keys) }}
2 theme calls to gridstack.html.twig
- GridStackEnginePluginBase::buildNestedItems in src/
GridStackEnginePluginBase.php - Provides nested items if so configured.
- GridStackManager::build in src/
GridStackManager.php - Returns a cacheable renderable array of a single gridstack instance.
File
templates/gridstack.html.twigView source
- {#
- /**
- * @file
- * Default theme implementation for the GridStack template.
- *
- * Available variables:
- * - items: The array of items containing gridstack contents and captions.
- * - settings: A cherry-picked settings that mostly defines the box HTML or
- * layout, and none of JS settings/options which are defined at data-config.
- * - attributes: The array of attributes to hold classes, id and config data
- * containing JSON object aka JS settings the GridStack expects. We don't
- * store these JS settings in the normal <head>, but inline within
- * data-config attribute instead.
- *
- * Important!
- * If you are adding additional contents to any content-related variable here,
- * e.g.: aside, bottom, preface, postscript, etc., be sure to add your own key,
- * normally unique like UUID or module name, to not conflict against, or
- * nullify, module features, or other providers, e.g.:
- * Good: postscript.cta, or postscript.widget (This extends postscript)
- * Bad: postscript = cta (This overrides/ nullifies other postscripts with cta)
- *
- * Debug:
- * @see https://www.drupal.org/node/1906780
- * @see https://www.drupal.org/node/1903374
- * Use Kint: {{ kint(variable) }}
- * Dump all available variables and their contents: {{ dump() }}
- * Dump only the available variable keys: {{ dump(_context|keys) }}
- */
- #}
- {%
- set classes = [
- settings.optionset ? 'gridstack--' ~ settings.optionset|clean_class,
- settings.skin ? 'gridstack--skin--' ~ settings.skin|clean_class,
- ]
- %}
- {% spaceless %}
- {% if settings.use_wrapper %}
- <div{{ wrapper_attributes.addClass('gridstack-wrapper') }}>
- {% endif %}
-
- {# Extra contents for administration such as layout editor. #}
- {% block gridstack_aside %}
- {{ aside }}
- {% endblock %}
-
- {# Allows ungriding nested wrapper such as for parallax to work. #}
- {% if settings.ungrid is empty %}
- <{{ wrapper }}{{ attributes.addClass(settings.root ? classes) }}>
- {% endif %}
-
- {# Allows more complex layouts than regular plain list. Beware might break! #}
- {% if content_attributes is not empty %}<div{{ content_attributes }}>{% endif %}
-
- {% block gridstack_preface %}
- {{ preface }}
- {% endblock %}
-
- {{ items }}
-
- {% block gridstack_postscript %}
- {{ postscript }}
- {% endblock %}
-
- {% if content_attributes is not empty %}</div>{% endif %}
-
- {% if settings.ungrid is empty %}
- </{{ wrapper }}>
- {% endif %}
-
- {# Extra contents for alternative administration such as layout editor. #}
- {% block gridstack_bottom %}
- {{ bottom }}
- {% endblock %}
-
- {% if settings.use_wrapper %}
- </div>
- {% endif %}
- {% endspaceless %}