Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting keyword arguments for sort filter #255

Closed
patrickarlt opened this issue Jul 3, 2014 · 2 comments
Closed

Supporting keyword arguments for sort filter #255

patrickarlt opened this issue Jul 3, 2014 · 2 comments

Comments

@patrickarlt
Copy link

Yesterday I ran into an issue trying to use some of Nunjucks builtin filters

According to the Jinja docs the sort filter is able to accept keyword arguments for sorting arrays of objects

{% for post in posts|sort(attribute="date") %}
  <h3>{{ post.title }} <small>{{post.date}}</small></h3>
{% endfor %}

Which simply leaves the array of blog posts unsorted. Taking a quick look at the tests for sort it looks like filters don't support keyword arguments but this does work ...

{% for post in blog|sort(false, false, "title") %}
  <h3>{{ post.title }} <small>{{post.date}}</small></h3>
{% endfor %}

So my question is should the built in filters be documented in the Nunjucks site (rather then just linking to Jinja) I could move all the docs easily. Or should filters be modified to accept keyword arguments?

@ArmorDarks
Copy link

probably code should be updated to correspond latest Jinja changes regarding sort keywords

@jlongster
Copy link
Contributor

We've been meaning to document our filters and not rely on jinja's documentation. If someone wants to start that work, that would be great. And yes, we could probably improve sort by using keyword arguments (support already exists)

@jlongster jlongster changed the title Supporting keyword arguments for filters Supporting keyword arguments for sort filter Apr 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants