Created
May 19, 2014 14:14
-
-
Save mdcpepper/9bd219464aa4a9d124dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% macro datesBetween(startDate, endDate, currentDate = null) %} | |
{% import _self as self %} | |
{# initialize the currentDate from the startDate #} | |
{% if currentDate is null %} | |
{% set currentDate = startDate %} | |
{% endif %} | |
{# echo the current date, or the startDate if it's the first run #} | |
<li>{{ currentDate }}</li> | |
{# add a day #} | |
{% set currentDate = currentDate|date_modify('+1 day') %} | |
{# if we're not at the endDate yet, call ourself and carry on #} | |
{% if currentDate <= endDate %} | |
{{ self.datesBetween(startDate, endDate, currentDate) }} | |
{% endif %} | |
{% endmacro %} | |
{% import _self as self %} | |
{% set startDate = now %} | |
{% set endDate = now|date_modify('+1 week') %} | |
<ul> | |
{{ self.datesBetween(startDate, endDate) }} | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment