From 79445b864163868e183a1978a16546c1e656748f Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sat, 24 Oct 2020 20:06:21 +0100 Subject: [PATCH] Refactor existing event paragraph template References #241 --- .../paragraph/paragraph--event.html.twig | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/web/themes/custom/opdavies/templates/paragraph/paragraph--event.html.twig b/web/themes/custom/opdavies/templates/paragraph/paragraph--event.html.twig index 520b29a..e90ffb7 100644 --- a/web/themes/custom/opdavies/templates/paragraph/paragraph--event.html.twig +++ b/web/themes/custom/opdavies/templates/paragraph/paragraph--event.html.twig @@ -47,26 +47,30 @@ ] %} {% block paragraph %} + {% set date = paragraph.field_date.0.value %} + {% set is_remote = paragraph.field_remote.0.value %} + {% set location = paragraph.field_location.0.value %} + {% set name = paragraph.field_name.0.value %} + {% set url = paragraph.field_link.0.url %} - + {% block content %} - {% set url = paragraph.field_link.0.url %} - {% if url %} - {{ link(paragraph.field_name.0.value, url) -}} - {% else %} - {{ content.field_name -}} - {% endif -%} + {% if url %} + {{ link(name, url) -}} + {% else %} + {{ name -}} + {% endif -%} - {%- if content.field_location is not empty %} - {{ 'in'|t }} - {{ content.field_location }} + {%- if location is not empty %} + {{ 'in'|t }} + {{ location }} {%- endif %} - {% if paragraph.field_remote.0.value %} + {% if is_remote %} {{ '(Remote)'|t }} {% endif %} - - {{ paragraph.field_date.0.value|date('jS F Y') }} + - {{ date|date('jS F Y') }} {{ content.without('field_remote') }} {% endblock %}