Extended {%ifchanged %} syntax to accept parameters #24

Merged
merged 1 commit into from May 7, 2012

Conversation

Projects
None yet
2 participants
@thge
Contributor

thge commented May 7, 2012

Django ifchanged can accept parameters, so it is possible to check for a value
which does not appear in output. Django documentation says to support one or
more parameters, this implementation supports up to 4 paramters (only limited
by the parser expression, this can be improved to support even more
parameters when needed).

{% for date in list %}
{% ifchanged date.month %}
{{ date.month }}:{{ date.day }}
{% else %}
{{ date.day }}
{% endifchanged %}
{% endfor %}

See erlydtl_unittests for some other examples.

The other (Django) syntax to use {% ifchanged %} without parameter works like before.

Support {% ifchanged Expression(s) %} like Django does
Django ifchanged can accept parameters, so it is possible to check for a value
which does not appear in output. Django documentation says to support one or
more parameters, this implementation supports up to 4 paramters (only limited
by the parser expression, this can be improved to support even more
parameters when needed).

{% for date in list %}
  {% ifchanged date.month %}
     {{ date.month }}:{{ date.day }}
  {% else %}
     {{ date.day }}
  {% endifchanged %}
{% endfor %}

See erlydtl_unittests for some other examples.

The other (Django) syntax to use {% ifchanged %} without parameter works like before.
@evanmiller

This comment has been minimized.

Show comment Hide comment
@evanmiller

evanmiller May 7, 2012

Contributor

Great work! The only thing that raises an eyebrow is the limit on parameters. I think we can make the syntax more general to support an arbitrary number, but for now, four parameters ought to be enough for anyone.

Contributor

evanmiller commented May 7, 2012

Great work! The only thing that raises an eyebrow is the limit on parameters. I think we can make the syntax more general to support an arbitrary number, but for now, four parameters ought to be enough for anyone.

evanmiller added a commit that referenced this pull request May 7, 2012

Merge pull request #24 from thge/master
Extended {%ifchanged %} syntax to accept parameters

@evanmiller evanmiller merged commit caa53a0 into erlydtl:master May 7, 2012

@thge

This comment has been minimized.

Show comment Hide comment
@thge

thge May 13, 2012

Contributor

On 05/07/2012 04:14 PM, Evan Miller wrote:

Great work! The only thing that raises an eyebrow is the limit on parameters.
I think we can make the syntax more general to support an arbitrary
number, but for now, four parameters ought to be enough for anyone.

I also think the the limited number of parameters is a flaw, but my yecc
knowledge is also limited, so I failed to build an expression with an
unlimited number of parameters. The erlang part is ready to accept any
number of parameters.

Thomas


Reply to this email directly or view it on GitHub:
evanmiller#24 (comment)

Contributor

thge commented May 13, 2012

On 05/07/2012 04:14 PM, Evan Miller wrote:

Great work! The only thing that raises an eyebrow is the limit on parameters.
I think we can make the syntax more general to support an arbitrary
number, but for now, four parameters ought to be enough for anyone.

I also think the the limited number of parameters is a flaw, but my yecc
knowledge is also limited, so I failed to build an expression with an
unlimited number of parameters. The erlang part is ready to accept any
number of parameters.

Thomas


Reply to this email directly or view it on GitHub:
evanmiller#24 (comment)

@evanmiller

This comment has been minimized.

Show comment Hide comment
@evanmiller

evanmiller May 13, 2012

Contributor

Here's a patch that supports unlimited parameters in the parser, and makes a few stylistic changes to the Erlang part:

165b1bf

Contributor

evanmiller commented May 13, 2012

Here's a patch that supports unlimited parameters in the parser, and makes a few stylistic changes to the Erlang part:

165b1bf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment