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

Add python slice support to jinja-compat. #976

Merged
merged 2 commits into from
May 11, 2017

Conversation

fdintino
Copy link
Collaborator

@fdintino fdintino commented Mar 31, 2017

Summary

Proposed change:

This pull-request adds support for python-style slice support (e.g. arr[start:stop:step]).

jinja-compat.js is the only file in this project that indents with two spaces, so my first commit changes it to four-space indent to bring it in conformity with the rest of the project.

There were not any existing tests for jinja compatibility, so I had to make some slight changes to the unit tests to have it work. Part of these changes was having nunjucks.installJinjaCompat return a function that, when called, undoes the jinja-compat changes, so that the jinja changes did not apply to other unit tests in the test suite. I wasn't sure if this was worth documenting in the API, since it strikes me as something that is unlikely to be used outside of the tests, but I would be happy to do so if requested.

Closes #188 .

Checklist

I've completed the checklist below to ensure I didn't forget anything. This makes reviewing this PR as easy as possible for the maintainers. And it gets this change released as soon as possible.

With regard to the first bullet point above, support for python slice syntax is expressly listed as a feature which falls outside the purpose of Nunjucks. But the same developer that wrote that statement of purpose also suggested in #188 that, if this functionality were to be added, it should be added to jinja-compat. So I assumed that means that while it shouldn't be assumed that nunjucks would support language-specific syntax, it isn't forbidden either. Under this assumption I've added that clarification to the purpose section of CONTRIBUTING.md.

@fdintino fdintino force-pushed the pr/slice-support-jinja-compat branch 2 times, most recently from a573282 to 82c2dbd Compare April 2, 2017 17:31
@fdintino fdintino force-pushed the pr/slice-support-jinja-compat branch from 82c2dbd to 1372175 Compare April 2, 2017 17:33
@fdintino
Copy link
Collaborator Author

fdintino commented Apr 3, 2017

@jbmoelker @vecmezoni wanted to make sure you saw this pull request. No rush of course.

@fdintino fdintino merged commit be0cfec into mozilla:master May 11, 2017
@zetareticoli
Copy link

When it'll be released?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Python's slice notation
2 participants