address: use renderAdress::renderLines in twig template

This commit is contained in:
nobohan 2022-01-06 17:02:17 +01:00
parent e82a71b833
commit 7d20f842a2

View File

@ -13,49 +13,13 @@
#}
{% macro raw(address, options, streetLine) %}
{% if address.street is not empty %}
<p>{{ streetLine }}</p>
{% endif %}
{% if options['extended_infos'] %}
{{ _self.extended(address, options) }}
{% endif %}
{% if address.postCode is not empty %}
<p class="postcode">
<span class="code">{{ address.postCode.code }}</span>
<span class="name">{{ address.postCode.name }}</span>
<span class="name">{{ address.distribution }}</span>
</p>
<p class="country">{{ address.postCode.country.name|localize_translatable_string }}</p>
{% endif %}
{% macro raw(lines) %}
{% for l in lines %}
<div>{{ l }}</div>
{% endfor %}
{% endmacro %}
{% macro extended(address, options) %}
{% if address.floor is not empty %}
<span class="floor">{{ 'address more.floor'|trans }} {{ address.floor }}</span>
{% endif %}
{% if address.corridor is not empty %}
<span class="corridor">{{ 'address more.corridor'|trans }} {{ address.corridor }}</span>
{% endif %}
{% if address.steps is not empty %}
<span class="steps">{{ 'address more.steps'|trans }} {{ address.steps }}</span>
{% endif %}
{% if address.buildingName is not empty %}
<span class="buildingName">{{ 'address more.buildingName'|trans }} {{ address.buildingName }}</span>
{% endif %}
{% if address.flat is not empty %}
<span class="flat">{{ 'address more.flat'|trans }} {{ address.flat }}</span>
{% endif %}
{% if address.extra is not empty %}
<span class="extra">{{ 'address more.extra'|trans }} {{ address.extra }}</span>
{% endif %}
{% if address.distribution is not empty %}
<span class="distribution">{{ 'address more.distribution'|trans }} {{ address.distribution }}</span>
{% endif %}
{% endmacro %}
{% macro inline(address, options, streetLine) %}
{% macro inline(address, options, streetLine, lines) %}
{% if options['has_no_address'] == true and address.isNoAddress == true %}
{% if address.postCode is not empty %}
<p class="postcode">
@ -69,9 +33,25 @@
{{ 'address.consider homeless'|trans }}
</span>
{% else %}
<span class="address{% if options['multiline'] %} multiline{% endif %}{% if options['with_delimiter'] %} delimiter{% endif %}">
{{ _self.raw(address, options, streetLine) }}
</span>
{% if options['extended_infos'] %}
<span class="address{% if options['multiline'] %} multiline{% endif %}{% if options['with_delimiter'] %} delimiter{% endif %}">
{{ _self.raw(lines) }}
</span>
{% else %}
<span class="address{% if options['multiline'] %} multiline{% endif %}{% if options['with_delimiter'] %} delimiter{% endif %}">
{% if address.street is not empty %}
<p>{{ streetLine }}</p>
{% endif %}
{% if address.postCode is not empty %}
<p class="postcode">
<span class="code">{{ address.postCode.code }}</span>
<span class="name">{{ address.postCode.name }}</span>
<span class="name">{{ address.distribution }}</span>
</p>
<p class="country">{{ address.postCode.country.name|localize_translatable_string }}</p>
{% endif %}
</span>
{% endif %}
{% endif %}
{{ _self.validity(address, options) }}
{% endmacro %}
@ -99,7 +79,7 @@
{% if options['with_picto'] %}
<i class="fa fa-li fa-map-marker"></i>
{% endif %}
{{ _self.inline(address, options, streetLine) }}
{{ _self.inline(address, options, streetLine, lines) }}
</li>
{%- endif -%}
@ -108,7 +88,7 @@
{% if options['with_picto'] %}
<i class="fa fa-fw fa-map-marker"></i>
{% endif %}
{{ _self.inline(address, options, streetLine) }}
{{ _self.inline(address, options, streetLine, lines) }}
</span>
{%- endif -%}
@ -134,7 +114,7 @@
{% if options['with_picto'] %}
<i class="fa fa-fw fa-map-marker"></i>
{% endif %}
{{ _self.raw(address, options, streetLine) }}
{{ _self.raw(lines) }}
</div>
{% endif %}
{{ _self.validity(address, options) }}