Skip to content

Instantly share code, notes, and snippets.

@markconroy
Created September 8, 2018 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markconroy/569c91f9893f411bec282a4633891fa6 to your computer and use it in GitHub Desktop.
Save markconroy/569c91f9893f411bec282a4633891fa6 to your computer and use it in GitHub Desktop.
{%
set classes = [
"card",
card_image ? 'card--has-image',
card_style ? 'card--' ~ card_style,
card_size ? 'card--' ~ card_size,
]
%}
{% if card_link_url %}
{% set element = 'a' %}
{% else %}
{% set element = 'div' %}
{% endif %}
<{{element}}{{ attributes.addClass(classes) }}{% if card_link_url %} href="{{ card_link_url}}"{% endif %}>
{% if card_image %}
<div class="card__image">
{{ card_image }}
</div>
{% endif %}
<div class="card__content">
{% if card_title %}
<div class="card__title h1">
{{ card_title }}
</div>
{% endif %}
{% if card_text %}
<div class="card__text">
{{ card_text }}
</div>
{% endif %}
</div>
</{{element}}>
{% block content_variable %}
{#
This allows the cache_context to bubble up for us, without having to
individually list every field in
{{ content|without('field_name', 'field_other_field', 'field_etc') }}
#}
{% set catch_cache = content|render %}
{% endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment