So I'm using dotLiquid (1.8.0) in my Project to create some HTML-Templates which are used to create PDFs via EO.pdf
So basically, I want to check if the given dates of an array of Days (== Dates) are in one week and add a page break after each week.
To make my problem more clear, here's the relevant code first:
{% for day in plan.Days %}
...
<table>
<tbody>
<tr class="footnote">
<td>** Debug:</td>
</tr>
<tr><td>Index: {{forloop.index}}, DateTypeChoice: {{plan.DateTypeChoice }}</td> <!-- just debug-statements -->
</tr>
</tbody>
</table>
{% assign endofweek = forloop.index | modulo: plan.DateTypeChoice %}
<p>endofweek: {{endofweek}}</p>
{%if endofweek == 0 %}
<p>"dubididu Index: " {{forloop.index}}</p>
<div style="page-break-before: always"></div>
{% endif %}
{% endfor %}
</body>
</html>
plan.DateTypeChoice
is an integer-value containing the number of days of a week (5 or 7 days). It is defined in my Drop-Model as
public int DateTypeChoice { get; set; }
Now in my test-scenario, the debug-statements (Index
and DateTypeChoice
) are showing the values I expect, but actually endofweek
contains for example (see below) 5
instead of 0
and I don't know why it is.
example output is:
** Debug:
Index: 5, DateTypeChoice: 5
endofweek: 5 // This should be 0 imho
I also tried to put brackets to the assignment, like
{% assign endofweek = (forloop.index | modulo: plan.DateTypeChoice) %}
but then I get an error thrown (value can'T be NULL).
I hope someone could help me out here. Perhaps I am using modulo wrong? As I know, forloop.index is a numeric value and numeric values given to the template from the model are treated as numeric values by the parser, too, so I am out of ideas.
Edit:
Based on this thread, I tried it with capturing instead of assigning, but same result. Code:
{% capture endofweek %} {{ forloop.index | modulo: plan.DateTypeChoice }}{% endcapture %}
<p>"endofweek: " {{endofweek}}</p> //again 5 :-(
{%if endofweek == 0 %}
Help is really appreciated here :-)