-
Notifications
You must be signed in to change notification settings - Fork 300
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
Allow iteration on a string #620
Conversation
Not really, more like an oversight. If it works in Jinja2, it should work here as well in this case. |
@Stepland are you interested in implementing iteration on strings? |
I'll try ! |
I first tried repurposing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but can you add some tests?
Actually wait, using |
Nice catch ! I added only one test. I think it is enough to check that string iteration gives back grapheme clusters and not something else like codepoints. I feel like adding more tests would just result in testing |
Make unic-segment required
Thanks, I'll merge/release it next week! |
I should stop giving time estimates haha |
I wanted to add some silly per-character rainbow text for my own blog with this style

I managed to do so with
split
but it feels hackyAdding the ability to iterate on characters with a filter reduces it to
I feel like tera not allowing strings to be iterated on directly was intentional so I chose to implement it as a filter. Using filters also allows for other ways of iterating on a string to be implemented, even though I can't think of another useful way to iterate on a string right now.