The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Dotiac::DTL::Tag::ifchanged - The {% ifchanged [VARIABLE] %} tag

SYNOPSIS

Template file:

{% for x in loop %}
	{% ifchanged %}
		Posted on {{ x.date }}
	{% endifchanged %}
	{% ifchanged x.poster %}
		Reply by {{ x.poster }} on {{ x.date }}
	{% endifchanged %}
{% endfor %}

DESCRIPTION

Without VARIABLE, ifchanged only renders its content, if the content changed since the last iteration of a loop above.

With VARIABLE, ifchanged only renders its content, if VARIABLE has changed since the last iteration of a loop above.

Note

Every ifchanged stands on its own, even if they have the same variable or content to check.

{% ifchanged x.post %}
	... {# This will be displayed #}
{% endifchanged %}
{% ifchanged x.post %}
	... {# This will also be displayed #}
{% endifchanged %}

BUGS AND DIFFERENCES TO DJANGO

This implementation also supports the {% else %} tag in ifchanged, which is not included in Django, but there is a patch for that.

{% for timepoint in timepoints %}
	{% ifchanged timepoint.day %}
		It's a new day.
	{% else %}
		It's still {{ timepoint.day }}
	{% endifchanged %}
{% endfor %}

SEE ALSO

http://www.djangoproject.com, Dotiac::DTL

LEGAL

Dotiac::DTL was built according to http://docs.djangoproject.com/en/dev/ref/templates/builtins/.

AUTHOR

Marc-Sebastian Lucksch

perl@marc-s.de