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

Implement 'slice' filter #141

Closed
flexferrum opened this issue Sep 25, 2019 · 3 comments
Closed

Implement 'slice' filter #141

flexferrum opened this issue Sep 25, 2019 · 3 comments
Labels
enhancement New feature or request hacktoberfest Issues for Hacktoberfest sooooo cute! Good for newcomers

Comments

@flexferrum
Copy link
Collaborator

Implement slice filter according the jinja2 documentation:

Slice an iterator and return a list of lists containing those items.
If you pass it a second argument it’s used to fill missing values on the last iteration.

For instance, slice(3, 0) applied to the list [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] should give the list of lists of three items each:

[[1, 2, 3],
 [4, 5, 6],
 [7, 8, 9],
 [10, 11, 12],
 [13, 14, 15],
 [16, 0, 0]]
@flexferrum flexferrum added enhancement New feature or request hacktoberfest Issues for Hacktoberfest sooooo cute! Good for newcomers labels Sep 25, 2019
@gupta409
Copy link

I can do this. Please feel free to assign.

@flexferrum
Copy link
Collaborator Author

I can do this. Please feel free to assign.

Thanks a lot!

@flexferrum
Copy link
Collaborator Author

flexferrum commented Sep 26, 2019

One notice before the implementation. There are two types of lists in the Jinja2C++ engine: which supports indexing and which doesn't (generator-based lists, lists over the forward-only iterators etc.). For lists with indexing available it's possible to use generators to produce slicing. For lists without indexing it's better to make a sliced copy of the original list.

@gupta409 gupta409 removed their assignment Oct 4, 2019
0x17de added a commit to 0x17de/Jinja2Cpp that referenced this issue Oct 13, 2019
flexferrum pushed a commit that referenced this issue Oct 15, 2019
* filter slice: implement non-batch version with tests (#141)

* filter slice: review: implement non-batch version with tests (#141)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest Issues for Hacktoberfest sooooo cute! Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants