Skip to content

Commit

Permalink
Update history_table template to support multi-dimensional arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
Amunak authored Feb 17, 2017
1 parent 509aa14 commit 58cb93b
Showing 1 changed file with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
{% macro formatValue(key, value) %}
{% if value.timestamp is defined %}
{{ value|date() }}
{% elseif key == 'price' or key == 'unitPrice' %}
{{ value|sylius_price() }}
{% elseif value is empty %}
<em>{{ 'sylius.history.empty'|trans }}</em>
{% else %}
{{ value }}
{% endif %}
{% if value.timestamp is defined %}
{{ value|date() }}
{% elseif key == 'price' or key == 'unitPrice' %}
{{ value|sylius_price() }}
{% elseif value is empty %}
<em>{{ 'sylius.history.empty'|trans }}</em>
{% else %}
{{ value }}
{% endif %}
{% endmacro %}

{% macro formatMixedValue(key, value) %}
{% if value is iterable %}
<ul>
{% for k, v in value %}
<li>{{ k|humanize }}: {{ _self.formatMixedValue(k, v) }}</li>
{% endfor %}
</ul>
{% else %}
{{ _self.formatValue(key, value) }}
{% endif %}
{% endmacro %}

{% set length = logs|length %}
Expand All @@ -33,15 +45,7 @@
{% for key, value in log.data %}
<li>
<strong>{{ key|humanize }}</strong>:
{% if value is iterable %}
<ul>
{% for k, v in value %}
<li>{{ k|humanize }}: {{ _self.formatValue(k, v) }}</li>
{% endfor %}
</ul>
{% else %}
{{ _self.formatValue(key, value) }}
{% endif %}
{{ _self.formatMixedValue(key, value) }}
</li>
{% endfor %}
</ul>
Expand Down

0 comments on commit 58cb93b

Please sign in to comment.