From 78ba2107ceacb7ec47a7503233f281e727801fee Mon Sep 17 00:00:00 2001 From: Nestor de Dios Fernandez Date: Mon, 29 Nov 2021 16:10:54 +0100 Subject: [PATCH 01/10] Allow prefix and postfix text on relationships input field --- templates/content/_relationships.html.twig | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/templates/content/_relationships.html.twig b/templates/content/_relationships.html.twig index 43f9e308e..cea6a8c3a 100644 --- a/templates/content/_relationships.html.twig +++ b/templates/content/_relationships.html.twig @@ -2,9 +2,20 @@ {% for contentType, relation in record.definition.relations %} {% set options = related_options(contentType, relation.order|default(), relation.format|default(), relation.required) %} - {% set value = record|related_values(contentType) %} + {% set value = record|related_values(contentType) %}{# Set the prefix and postfix attributes #} + + {% set prefix = prefix|default(relation['prefix']|default) %} + {% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %} + {% endif %} + + {% set postfix = postfix|default(relation['postfix']|default) %} + {% if postfix and not (postfix starts with '' ~ postfix|markdown ~ '' %} + {% endif %}
+ {{ prefix|raw }} {% include '@bolt/_partials/fields/_label.html.twig' with { 'id': 'relationship-' ~ contentType, @@ -25,6 +36,8 @@ >
+ {{ postfix|raw }} + {% endfor %} From 619d6a2a0875c8ab2a1d22bf4cc46cc710f18949 Mon Sep 17 00:00:00 2001 From: Nestor de Dios Fernandez Date: Mon, 29 Nov 2021 16:25:48 +0100 Subject: [PATCH 02/10] Allow prefix and postfix text on taxonomies input field --- templates/content/_taxonomies.html.twig | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/templates/content/_taxonomies.html.twig b/templates/content/_taxonomies.html.twig index 735ccb8a2..bef4fa459 100644 --- a/templates/content/_taxonomies.html.twig +++ b/templates/content/_taxonomies.html.twig @@ -6,8 +6,20 @@ {% set options = taxonomy_options(definition) %} {% set value = taxonomy_values(record.taxonomies, definition) %} + {% set prefix = prefix|default(definition['prefix']|default) %} + {% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %} + {% endif %} + + {% set postfix = postfix|default(definition['postfix']|default) %} + {% if postfix and not (postfix starts with '' ~ postfix|markdown ~ '' %} + {% endif %} +
+ {{ prefix|raw }} + {% include '@bolt/_partials/fields/_label.html.twig' with { 'id': 'taxonomy-' ~ definition.slug, 'label': definition.name, @@ -26,6 +38,8 @@ >
+ {{ postfix|raw }} + {% endif %} From cd9143cd4bf530d9bcf94fcaedb6e7b00dbfcb5e Mon Sep 17 00:00:00 2001 From: Nestor de Dios Fernandez Date: Mon, 29 Nov 2021 16:38:30 +0100 Subject: [PATCH 03/10] Add comment to prefix and postfix variables definitions --- templates/content/_relationships.html.twig | 3 ++- templates/content/_taxonomies.html.twig | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/templates/content/_relationships.html.twig b/templates/content/_relationships.html.twig index cea6a8c3a..4f65663d0 100644 --- a/templates/content/_relationships.html.twig +++ b/templates/content/_relationships.html.twig @@ -2,8 +2,9 @@ {% for contentType, relation in record.definition.relations %} {% set options = related_options(contentType, relation.order|default(), relation.format|default(), relation.required) %} - {% set value = record|related_values(contentType) %}{# Set the prefix and postfix attributes #} + {% set value = record|related_values(contentType) %} + {# Set the prefix and postfix attributes #} {% set prefix = prefix|default(relation['prefix']|default) %} {% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %} diff --git a/templates/content/_taxonomies.html.twig b/templates/content/_taxonomies.html.twig index bef4fa459..ba83d167a 100644 --- a/templates/content/_taxonomies.html.twig +++ b/templates/content/_taxonomies.html.twig @@ -5,7 +5,8 @@ {% set options = taxonomy_options(definition) %} {% set value = taxonomy_values(record.taxonomies, definition) %} - + + {# Set the prefix and postfix attributes #} {% set prefix = prefix|default(definition['prefix']|default) %} {% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %} From 88d8eaa2980a46aa1307de6945b221e5835c413c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9stor=20de=20Dios=20Fern=C3=A1ndez?= Date: Wed, 1 Dec 2021 14:36:25 +0100 Subject: [PATCH 04/10] Add generatePrefix() and generatePostfix() macros --- templates/_macro/_macro.html.twig | 22 ++++++++++++++++++ templates/_partials/fields/_base.html.twig | 27 ++++++++++++++-------- templates/content/_relationships.html.twig | 23 +++++++++--------- templates/content/_taxonomies.html.twig | 27 +++++++++++----------- 4 files changed, 65 insertions(+), 34 deletions(-) diff --git a/templates/_macro/_macro.html.twig b/templates/_macro/_macro.html.twig index efea573a4..20d989a0f 100644 --- a/templates/_macro/_macro.html.twig +++ b/templates/_macro/_macro.html.twig @@ -98,3 +98,25 @@ {{- datetime|date('c') -}} {% endapply %}{% endmacro %} + +{# + Variables + 'prefix': Is the prefix string + 'id': Is a string +#} +{% macro generatePrefix(prefix, id) %}{% apply spaceless %} + {% if prefix and not (prefix starts with '{{ prefix|markdown }} + {% endif %} +{% endapply %}{% endmacro %} + +{# + Variables + 'postfix': Is the postfix string + 'id': Is a string +#} +{% macro generatePostfix(postfix, id) %}{% apply spaceless %} + {% if postfix and not (postfix starts with '{{ postfix|markdown }} + {% endif %} +{% endapply %}{% endmacro %} diff --git a/templates/_partials/fields/_base.html.twig b/templates/_partials/fields/_base.html.twig index cf98cea19..eac03d927 100644 --- a/templates/_partials/fields/_base.html.twig +++ b/templates/_partials/fields/_base.html.twig @@ -1,3 +1,5 @@ +{% import '_macro/_macro.html.twig' as macro %} + {%- apply spaceless -%} {# This template fragment is used to "extend" the different fields, used in @@ -120,16 +122,17 @@ {# Set the locale #} {% set localize = field.definition.localize|default %} + {# Set the prefix and postfix attributes #} -{% set prefix = prefix|default(field.definition.prefix|default) %} -{% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %} -{% endif %} +{#{% set prefix = prefix|default(field.definition.prefix|default) %}#} +{#{% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %}#} +{#{% endif %}#} -{% set postfix = postfix|default(field.definition.postfix|default) %} -{% if postfix and not (postfix starts with '' ~ postfix|markdown ~ '' %} -{% endif %} +{#{% set postfix = postfix|default(field.definition.postfix|default) %}#} +{#{% if postfix and not (postfix starts with '' ~ postfix|markdown ~ '' %}#} +{#{% endif %}#} {%- endapply -%} @@ -139,7 +142,9 @@ id="field--{{ id }}" > -{{ prefix|raw }} +{% if field.definition['prefix']|default() is not empty %} + {{ macro.generatePrefix(field.definition['prefix']|default(), id) }} +{% endif %} {% if variant == 'inline' %}
{% endif %} @@ -158,7 +163,9 @@ {% if variant == 'inline' %}
{% endif %} -{{ postfix|raw }} +{% if field.definition['postfix']|default() is not empty %} + {{ macro.generatePostfix(field.definition['postfix']|default(), id) }} +{% endif %} {{ separator|raw }} diff --git a/templates/content/_relationships.html.twig b/templates/content/_relationships.html.twig index 4f65663d0..9aff37483 100644 --- a/templates/content/_relationships.html.twig +++ b/templates/content/_relationships.html.twig @@ -1,22 +1,23 @@ - +{% import '_macro/_macro.html.twig' as macro %} {% for contentType, relation in record.definition.relations %} {% set options = related_options(contentType, relation.order|default(), relation.format|default(), relation.required) %} {% set value = record|related_values(contentType) %} {# Set the prefix and postfix attributes #} - {% set prefix = prefix|default(relation['prefix']|default) %} - {% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %} - {% endif %} +{# {% set prefix = prefix|default(relation['prefix']|default) %}#} +{# {% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %}#} +{# {% endif %}#} - {% set postfix = postfix|default(relation['postfix']|default) %} - {% if postfix and not (postfix starts with '' ~ postfix|markdown ~ '' %} - {% endif %} +{# {% set postfix = postfix|default(relation['postfix']|default) %}#} +{# {% if postfix and not (postfix starts with '' ~ postfix|markdown ~ '' %}#} +{# {% endif %}#}
- {{ prefix|raw }} + + {{ macro.generatePrefix(relation['prefix']|default, contentType) }} {% include '@bolt/_partials/fields/_label.html.twig' with { 'id': 'relationship-' ~ contentType, @@ -37,7 +38,7 @@ >
- {{ postfix|raw }} + {{ macro.generatePostfix(relation['postfix']|default, contentType) }} diff --git a/templates/content/_taxonomies.html.twig b/templates/content/_taxonomies.html.twig index ba83d167a..6489228d9 100644 --- a/templates/content/_taxonomies.html.twig +++ b/templates/content/_taxonomies.html.twig @@ -1,3 +1,4 @@ +{% import '_macro/_macro.html.twig' as macro %} {% for taxonomy in record.definition.taxonomy %} {% set definition = config.get('taxonomies/' ~ taxonomy) %} @@ -5,21 +6,21 @@ {% set options = taxonomy_options(definition) %} {% set value = taxonomy_values(record.taxonomies, definition) %} - - {# Set the prefix and postfix attributes #} - {% set prefix = prefix|default(definition['prefix']|default) %} - {% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %} - {% endif %} - - {% set postfix = postfix|default(definition['postfix']|default) %} - {% if postfix and not (postfix starts with '' ~ postfix|markdown ~ '' %} - {% endif %} + +{# #}{# Set the prefix and postfix attributes #} +{# {% set prefix = prefix|default(definition['prefix']|default) %}#} +{# {% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %}#} +{# {% endif %}#} + +{# {% set postfix = postfix|default(definition['postfix']|default) %}#} +{# {% if postfix and not (postfix starts with '' ~ postfix|markdown ~ '' %}#} +{# {% endif %}#}
- {{ prefix|raw }} + {{ macro.generatePrefix(definition['prefix'], taxonomy) }} {% include '@bolt/_partials/fields/_label.html.twig' with { 'id': 'taxonomy-' ~ definition.slug, @@ -39,7 +40,7 @@ >
- {{ postfix|raw }} + {{ macro.generatePostfix(definition['postfix'], taxonomy) }} From 2ff62aceef3aec1b0ed473a231ea0f9693fb47fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9stor=20de=20Dios=20Fern=C3=A1ndez?= Date: Wed, 1 Dec 2021 14:45:17 +0100 Subject: [PATCH 05/10] Cleanup and checks for printing --- templates/_partials/fields/_base.html.twig | 14 ++------------ templates/content/_relationships.html.twig | 22 +++++++++------------- templates/content/_taxonomies.html.twig | 22 +++++++++------------- 3 files changed, 20 insertions(+), 38 deletions(-) diff --git a/templates/_partials/fields/_base.html.twig b/templates/_partials/fields/_base.html.twig index eac03d927..0aefadea2 100644 --- a/templates/_partials/fields/_base.html.twig +++ b/templates/_partials/fields/_base.html.twig @@ -122,18 +122,6 @@ {# Set the locale #} {% set localize = field.definition.localize|default %} - -{# Set the prefix and postfix attributes #} -{#{% set prefix = prefix|default(field.definition.prefix|default) %}#} -{#{% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %}#} -{#{% endif %}#} - -{#{% set postfix = postfix|default(field.definition.postfix|default) %}#} -{#{% if postfix and not (postfix starts with '' ~ postfix|markdown ~ '' %}#} -{#{% endif %}#} - {%- endapply -%} @@ -142,6 +130,7 @@ id="field--{{ id }}" > +{# Print prefix #} {% if field.definition['prefix']|default() is not empty %} {{ macro.generatePrefix(field.definition['prefix']|default(), id) }} {% endif %} @@ -163,6 +152,7 @@ {% if variant == 'inline' %}{% endif %} +{# Print postfix #} {% if field.definition['postfix']|default() is not empty %} {{ macro.generatePostfix(field.definition['postfix']|default(), id) }} {% endif %} diff --git a/templates/content/_relationships.html.twig b/templates/content/_relationships.html.twig index 9aff37483..fa4a9ccff 100644 --- a/templates/content/_relationships.html.twig +++ b/templates/content/_relationships.html.twig @@ -1,23 +1,16 @@ {% import '_macro/_macro.html.twig' as macro %} + {% for contentType, relation in record.definition.relations %} {% set options = related_options(contentType, relation.order|default(), relation.format|default(), relation.required) %} {% set value = record|related_values(contentType) %} - {# Set the prefix and postfix attributes #} -{# {% set prefix = prefix|default(relation['prefix']|default) %}#} -{# {% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %}#} -{# {% endif %}#} - -{# {% set postfix = postfix|default(relation['postfix']|default) %}#} -{# {% if postfix and not (postfix starts with '' ~ postfix|markdown ~ '' %}#} -{# {% endif %}#} -
- {{ macro.generatePrefix(relation['prefix']|default, contentType) }} + {# Print prefix #} + {% if relation['prefix']|default() is not empty %} + {{ macro.generatePrefix(relation['prefix']|default, contentType) }} + {% endif %} {% include '@bolt/_partials/fields/_label.html.twig' with { 'id': 'relationship-' ~ contentType, @@ -38,7 +31,10 @@ >
- {{ macro.generatePostfix(relation['postfix']|default, contentType) }} + {# Print postfix #} + {% if relation['postfix']|default() is not empty %} + {{ macro.generatePostfix(relation['postfix']|default, contentType) }} + {% endif %} diff --git a/templates/content/_taxonomies.html.twig b/templates/content/_taxonomies.html.twig index 6489228d9..719edbf93 100644 --- a/templates/content/_taxonomies.html.twig +++ b/templates/content/_taxonomies.html.twig @@ -1,4 +1,5 @@ {% import '_macro/_macro.html.twig' as macro %} + {% for taxonomy in record.definition.taxonomy %} {% set definition = config.get('taxonomies/' ~ taxonomy) %} @@ -7,20 +8,12 @@ {% set options = taxonomy_options(definition) %} {% set value = taxonomy_values(record.taxonomies, definition) %} -{# #}{# Set the prefix and postfix attributes #} -{# {% set prefix = prefix|default(definition['prefix']|default) %}#} -{# {% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %}#} -{# {% endif %}#} - -{# {% set postfix = postfix|default(definition['postfix']|default) %}#} -{# {% if postfix and not (postfix starts with '' ~ postfix|markdown ~ '' %}#} -{# {% endif %}#} -
- {{ macro.generatePrefix(definition['prefix'], taxonomy) }} + {# Print prefix #} + {% if definition['prefix']|default() is not empty %} + {{ macro.generatePrefix(definition['prefix'], taxonomy) }} + {% endif %} {% include '@bolt/_partials/fields/_label.html.twig' with { 'id': 'taxonomy-' ~ definition.slug, @@ -40,7 +33,10 @@ >
- {{ macro.generatePostfix(definition['postfix'], taxonomy) }} + {# Print postfix #} + {% if definition['postfix']|default() is not empty %} + {{ macro.generatePostfix(definition['postfix'], taxonomy) }} + {% endif %} From 79a25b7dc678e453aba22160a17ee92949d1f6f0 Mon Sep 17 00:00:00 2001 From: Nestor de Dios Fernandez Date: Mon, 29 Nov 2021 16:10:54 +0100 Subject: [PATCH 06/10] Allow prefix and postfix text on relationships input field --- templates/content/_relationships.html.twig | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/templates/content/_relationships.html.twig b/templates/content/_relationships.html.twig index 43f9e308e..cea6a8c3a 100644 --- a/templates/content/_relationships.html.twig +++ b/templates/content/_relationships.html.twig @@ -2,9 +2,20 @@ {% for contentType, relation in record.definition.relations %} {% set options = related_options(contentType, relation.order|default(), relation.format|default(), relation.required) %} - {% set value = record|related_values(contentType) %} + {% set value = record|related_values(contentType) %}{# Set the prefix and postfix attributes #} + + {% set prefix = prefix|default(relation['prefix']|default) %} + {% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %} + {% endif %} + + {% set postfix = postfix|default(relation['postfix']|default) %} + {% if postfix and not (postfix starts with '' ~ postfix|markdown ~ '' %} + {% endif %}
+ {{ prefix|raw }} {% include '@bolt/_partials/fields/_label.html.twig' with { 'id': 'relationship-' ~ contentType, @@ -25,6 +36,8 @@ >
+ {{ postfix|raw }} + {% endfor %} From f8093762e3a0f4052d77dee2e5588c71e9db86a3 Mon Sep 17 00:00:00 2001 From: Nestor de Dios Fernandez Date: Mon, 29 Nov 2021 16:25:48 +0100 Subject: [PATCH 07/10] Allow prefix and postfix text on taxonomies input field --- templates/content/_taxonomies.html.twig | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/templates/content/_taxonomies.html.twig b/templates/content/_taxonomies.html.twig index 735ccb8a2..bef4fa459 100644 --- a/templates/content/_taxonomies.html.twig +++ b/templates/content/_taxonomies.html.twig @@ -6,8 +6,20 @@ {% set options = taxonomy_options(definition) %} {% set value = taxonomy_values(record.taxonomies, definition) %} + {% set prefix = prefix|default(definition['prefix']|default) %} + {% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %} + {% endif %} + + {% set postfix = postfix|default(definition['postfix']|default) %} + {% if postfix and not (postfix starts with '' ~ postfix|markdown ~ '' %} + {% endif %} +
+ {{ prefix|raw }} + {% include '@bolt/_partials/fields/_label.html.twig' with { 'id': 'taxonomy-' ~ definition.slug, 'label': definition.name, @@ -26,6 +38,8 @@ >
+ {{ postfix|raw }} + {% endif %} From a473eea197c201b438a39f60b589d963018f62e5 Mon Sep 17 00:00:00 2001 From: Nestor de Dios Fernandez Date: Mon, 29 Nov 2021 16:38:30 +0100 Subject: [PATCH 08/10] Add comment to prefix and postfix variables definitions --- templates/content/_relationships.html.twig | 3 ++- templates/content/_taxonomies.html.twig | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/templates/content/_relationships.html.twig b/templates/content/_relationships.html.twig index cea6a8c3a..4f65663d0 100644 --- a/templates/content/_relationships.html.twig +++ b/templates/content/_relationships.html.twig @@ -2,8 +2,9 @@ {% for contentType, relation in record.definition.relations %} {% set options = related_options(contentType, relation.order|default(), relation.format|default(), relation.required) %} - {% set value = record|related_values(contentType) %}{# Set the prefix and postfix attributes #} + {% set value = record|related_values(contentType) %} + {# Set the prefix and postfix attributes #} {% set prefix = prefix|default(relation['prefix']|default) %} {% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %} diff --git a/templates/content/_taxonomies.html.twig b/templates/content/_taxonomies.html.twig index bef4fa459..ba83d167a 100644 --- a/templates/content/_taxonomies.html.twig +++ b/templates/content/_taxonomies.html.twig @@ -5,7 +5,8 @@ {% set options = taxonomy_options(definition) %} {% set value = taxonomy_values(record.taxonomies, definition) %} - + + {# Set the prefix and postfix attributes #} {% set prefix = prefix|default(definition['prefix']|default) %} {% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %} From 8a5a188b862a24ae9b1917995a9d55c3922464cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9stor=20de=20Dios=20Fern=C3=A1ndez?= Date: Wed, 1 Dec 2021 14:36:25 +0100 Subject: [PATCH 09/10] Add generatePrefix() and generatePostfix() macros --- templates/_macro/_macro.html.twig | 22 ++++++++++++++++++ templates/_partials/fields/_base.html.twig | 27 ++++++++++++++-------- templates/content/_relationships.html.twig | 23 +++++++++--------- templates/content/_taxonomies.html.twig | 27 +++++++++++----------- 4 files changed, 65 insertions(+), 34 deletions(-) diff --git a/templates/_macro/_macro.html.twig b/templates/_macro/_macro.html.twig index efea573a4..20d989a0f 100644 --- a/templates/_macro/_macro.html.twig +++ b/templates/_macro/_macro.html.twig @@ -98,3 +98,25 @@ {{- datetime|date('c') -}} {% endapply %}{% endmacro %} + +{# + Variables + 'prefix': Is the prefix string + 'id': Is a string +#} +{% macro generatePrefix(prefix, id) %}{% apply spaceless %} + {% if prefix and not (prefix starts with '{{ prefix|markdown }} + {% endif %} +{% endapply %}{% endmacro %} + +{# + Variables + 'postfix': Is the postfix string + 'id': Is a string +#} +{% macro generatePostfix(postfix, id) %}{% apply spaceless %} + {% if postfix and not (postfix starts with '{{ postfix|markdown }} + {% endif %} +{% endapply %}{% endmacro %} diff --git a/templates/_partials/fields/_base.html.twig b/templates/_partials/fields/_base.html.twig index cf98cea19..eac03d927 100644 --- a/templates/_partials/fields/_base.html.twig +++ b/templates/_partials/fields/_base.html.twig @@ -1,3 +1,5 @@ +{% import '_macro/_macro.html.twig' as macro %} + {%- apply spaceless -%} {# This template fragment is used to "extend" the different fields, used in @@ -120,16 +122,17 @@ {# Set the locale #} {% set localize = field.definition.localize|default %} + {# Set the prefix and postfix attributes #} -{% set prefix = prefix|default(field.definition.prefix|default) %} -{% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %} -{% endif %} +{#{% set prefix = prefix|default(field.definition.prefix|default) %}#} +{#{% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %}#} +{#{% endif %}#} -{% set postfix = postfix|default(field.definition.postfix|default) %} -{% if postfix and not (postfix starts with '' ~ postfix|markdown ~ '' %} -{% endif %} +{#{% set postfix = postfix|default(field.definition.postfix|default) %}#} +{#{% if postfix and not (postfix starts with '' ~ postfix|markdown ~ '' %}#} +{#{% endif %}#} {%- endapply -%} @@ -139,7 +142,9 @@ id="field--{{ id }}" > -{{ prefix|raw }} +{% if field.definition['prefix']|default() is not empty %} + {{ macro.generatePrefix(field.definition['prefix']|default(), id) }} +{% endif %} {% if variant == 'inline' %}
{% endif %} @@ -158,7 +163,9 @@ {% if variant == 'inline' %}
{% endif %} -{{ postfix|raw }} +{% if field.definition['postfix']|default() is not empty %} + {{ macro.generatePostfix(field.definition['postfix']|default(), id) }} +{% endif %} {{ separator|raw }} diff --git a/templates/content/_relationships.html.twig b/templates/content/_relationships.html.twig index 4f65663d0..9aff37483 100644 --- a/templates/content/_relationships.html.twig +++ b/templates/content/_relationships.html.twig @@ -1,22 +1,23 @@ - +{% import '_macro/_macro.html.twig' as macro %} {% for contentType, relation in record.definition.relations %} {% set options = related_options(contentType, relation.order|default(), relation.format|default(), relation.required) %} {% set value = record|related_values(contentType) %} {# Set the prefix and postfix attributes #} - {% set prefix = prefix|default(relation['prefix']|default) %} - {% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %} - {% endif %} +{# {% set prefix = prefix|default(relation['prefix']|default) %}#} +{# {% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %}#} +{# {% endif %}#} - {% set postfix = postfix|default(relation['postfix']|default) %} - {% if postfix and not (postfix starts with '' ~ postfix|markdown ~ '' %} - {% endif %} +{# {% set postfix = postfix|default(relation['postfix']|default) %}#} +{# {% if postfix and not (postfix starts with '' ~ postfix|markdown ~ '' %}#} +{# {% endif %}#}
- {{ prefix|raw }} + + {{ macro.generatePrefix(relation['prefix']|default, contentType) }} {% include '@bolt/_partials/fields/_label.html.twig' with { 'id': 'relationship-' ~ contentType, @@ -37,7 +38,7 @@ >
- {{ postfix|raw }} + {{ macro.generatePostfix(relation['postfix']|default, contentType) }} diff --git a/templates/content/_taxonomies.html.twig b/templates/content/_taxonomies.html.twig index ba83d167a..6489228d9 100644 --- a/templates/content/_taxonomies.html.twig +++ b/templates/content/_taxonomies.html.twig @@ -1,3 +1,4 @@ +{% import '_macro/_macro.html.twig' as macro %} {% for taxonomy in record.definition.taxonomy %} {% set definition = config.get('taxonomies/' ~ taxonomy) %} @@ -5,21 +6,21 @@ {% set options = taxonomy_options(definition) %} {% set value = taxonomy_values(record.taxonomies, definition) %} - - {# Set the prefix and postfix attributes #} - {% set prefix = prefix|default(definition['prefix']|default) %} - {% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %} - {% endif %} - - {% set postfix = postfix|default(definition['postfix']|default) %} - {% if postfix and not (postfix starts with '' ~ postfix|markdown ~ '' %} - {% endif %} + +{# #}{# Set the prefix and postfix attributes #} +{# {% set prefix = prefix|default(definition['prefix']|default) %}#} +{# {% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %}#} +{# {% endif %}#} + +{# {% set postfix = postfix|default(definition['postfix']|default) %}#} +{# {% if postfix and not (postfix starts with '' ~ postfix|markdown ~ '' %}#} +{# {% endif %}#}
- {{ prefix|raw }} + {{ macro.generatePrefix(definition['prefix'], taxonomy) }} {% include '@bolt/_partials/fields/_label.html.twig' with { 'id': 'taxonomy-' ~ definition.slug, @@ -39,7 +40,7 @@ >
- {{ postfix|raw }} + {{ macro.generatePostfix(definition['postfix'], taxonomy) }} From 81126e78800d30086638934286d3b85ee11127b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9stor=20de=20Dios=20Fern=C3=A1ndez?= Date: Wed, 1 Dec 2021 14:45:17 +0100 Subject: [PATCH 10/10] Cleanup and checks for printing --- templates/_partials/fields/_base.html.twig | 14 ++------------ templates/content/_relationships.html.twig | 22 +++++++++------------- templates/content/_taxonomies.html.twig | 22 +++++++++------------- 3 files changed, 20 insertions(+), 38 deletions(-) diff --git a/templates/_partials/fields/_base.html.twig b/templates/_partials/fields/_base.html.twig index eac03d927..0aefadea2 100644 --- a/templates/_partials/fields/_base.html.twig +++ b/templates/_partials/fields/_base.html.twig @@ -122,18 +122,6 @@ {# Set the locale #} {% set localize = field.definition.localize|default %} - -{# Set the prefix and postfix attributes #} -{#{% set prefix = prefix|default(field.definition.prefix|default) %}#} -{#{% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %}#} -{#{% endif %}#} - -{#{% set postfix = postfix|default(field.definition.postfix|default) %}#} -{#{% if postfix and not (postfix starts with '' ~ postfix|markdown ~ '' %}#} -{#{% endif %}#} - {%- endapply -%} @@ -142,6 +130,7 @@ id="field--{{ id }}" > +{# Print prefix #} {% if field.definition['prefix']|default() is not empty %} {{ macro.generatePrefix(field.definition['prefix']|default(), id) }} {% endif %} @@ -163,6 +152,7 @@ {% if variant == 'inline' %}{% endif %} +{# Print postfix #} {% if field.definition['postfix']|default() is not empty %} {{ macro.generatePostfix(field.definition['postfix']|default(), id) }} {% endif %} diff --git a/templates/content/_relationships.html.twig b/templates/content/_relationships.html.twig index 9aff37483..fa4a9ccff 100644 --- a/templates/content/_relationships.html.twig +++ b/templates/content/_relationships.html.twig @@ -1,23 +1,16 @@ {% import '_macro/_macro.html.twig' as macro %} + {% for contentType, relation in record.definition.relations %} {% set options = related_options(contentType, relation.order|default(), relation.format|default(), relation.required) %} {% set value = record|related_values(contentType) %} - {# Set the prefix and postfix attributes #} -{# {% set prefix = prefix|default(relation['prefix']|default) %}#} -{# {% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %}#} -{# {% endif %}#} - -{# {% set postfix = postfix|default(relation['postfix']|default) %}#} -{# {% if postfix and not (postfix starts with '' ~ postfix|markdown ~ '' %}#} -{# {% endif %}#} -
- {{ macro.generatePrefix(relation['prefix']|default, contentType) }} + {# Print prefix #} + {% if relation['prefix']|default() is not empty %} + {{ macro.generatePrefix(relation['prefix']|default, contentType) }} + {% endif %} {% include '@bolt/_partials/fields/_label.html.twig' with { 'id': 'relationship-' ~ contentType, @@ -38,7 +31,10 @@ >
- {{ macro.generatePostfix(relation['postfix']|default, contentType) }} + {# Print postfix #} + {% if relation['postfix']|default() is not empty %} + {{ macro.generatePostfix(relation['postfix']|default, contentType) }} + {% endif %} diff --git a/templates/content/_taxonomies.html.twig b/templates/content/_taxonomies.html.twig index 6489228d9..719edbf93 100644 --- a/templates/content/_taxonomies.html.twig +++ b/templates/content/_taxonomies.html.twig @@ -1,4 +1,5 @@ {% import '_macro/_macro.html.twig' as macro %} + {% for taxonomy in record.definition.taxonomy %} {% set definition = config.get('taxonomies/' ~ taxonomy) %} @@ -7,20 +8,12 @@ {% set options = taxonomy_options(definition) %} {% set value = taxonomy_values(record.taxonomies, definition) %} -{# #}{# Set the prefix and postfix attributes #} -{# {% set prefix = prefix|default(definition['prefix']|default) %}#} -{# {% if prefix and not (prefix starts with '' ~ prefix|markdown ~ '' %}#} -{# {% endif %}#} - -{# {% set postfix = postfix|default(definition['postfix']|default) %}#} -{# {% if postfix and not (postfix starts with '' ~ postfix|markdown ~ '' %}#} -{# {% endif %}#} -
- {{ macro.generatePrefix(definition['prefix'], taxonomy) }} + {# Print prefix #} + {% if definition['prefix']|default() is not empty %} + {{ macro.generatePrefix(definition['prefix'], taxonomy) }} + {% endif %} {% include '@bolt/_partials/fields/_label.html.twig' with { 'id': 'taxonomy-' ~ definition.slug, @@ -40,7 +33,10 @@ >
- {{ macro.generatePostfix(definition['postfix'], taxonomy) }} + {# Print postfix #} + {% if definition['postfix']|default() is not empty %} + {{ macro.generatePostfix(definition['postfix'], taxonomy) }} + {% endif %}