zomars / bolt-store-hours

An extension to add business hours as a field type within Bolt
3 stars 0 forks source link

[Feature] Handy Twig Function #2

Open Raistlfiren opened 8 years ago

Raistlfiren commented 8 years ago

It would be nice to add a TWIG function that requires a template file or uses a default template file specified in the config.yml.dist that allows the user to output data by default like this -

{% for hour in store_hours_hours_today(record.hours) %}
    {% set this_day_hours = hour|split('-') %}
    Open: {{ this_day_hours[0]|date('g:i a') }}
    Close: {{ this_day_hours[1]|date('g:i a') }}
{% endfor %}

or maybe it shows an example of outputting each one based upon the day.... Monday - Friday 7am to 3:30pm Sunday - Closed After Hours Support is Available

Then you could call a function outputStoreHoursFormatted(twigTemplate = defaut.twig).

zomars commented 7 years ago

Mi initial intention was to port the functions in PHP Store Hours (since that's the library I'm using).