How to display Opening Hours
Hours when the location is open. It needs to be a JSON object with the following structure:
- Each attribute indicates the opening hours for a day. Valid attributes: mon (Monday), tue, wed, thu, fri, sat, sun.
- Each day is an array with the list of opening hours for that day, such as one for the morning and one for the afternoon.
- Each opening hour is an object with the keys from and to.
- A day can have an empty array of hours. This indicates a closing day.
Get the hours for a day
{{ location.hours.mon }}
Display opening hours for a day
{% for range in location.hours.mon %}
{{ range.from }} - {{ range.to }}
{% if forloop.last == false %}, {% endif %}
{% endfor %}
Display opening hours in a human readable way
{% for day in location.hours %}
{% capture day_name %}
{% case day[0] %}
{% when 'mon' %} Monday
{% when 'tue' %} Tuesday
{% when 'wed' %} Wednesday
{% when 'thu' %} Thursday
{% when 'fri' %} Friday
{% when 'sat' %} Saturday
{% when 'sun' %} Sunday
{% endcase %}
{% endcapture %}
<b>{{ day_name }}</b>:
{% if day[1].size > 0 %}
{% for range in day[1] %}
{{ range.from }} - {{ range.to }}
{% if forloop.last == false %}, {% endif %}
{% endfor %}
{% else %}
Closed
{% endif %}
{% endfor %}