jinja icon indicating copy to clipboard operation
jinja copied to clipboard

matcher() builtin, like joiner() and cycler()

Open miracle2k opened this issue 12 years ago • 2 comments

Any interest in including something like this:

https://github.com/miracle2k/jinja2utils/blob/master/src/jinja2utils/match.py

I have just written this code a second time, needing it again and not remembering I had already implemented it once.

It seems to fit very well alongside joiner() and cycler(), and presumably is a common usecase.

miracle2k avatar Jan 21 '12 19:01 miracle2k

Not a bad idea. Though the default should probably be undefined for consistency with the inline if expression.

mitsuhiko avatar Jan 22 '12 02:01 mitsuhiko

Which value specifically do you suggest should default to undefined?

I have implemented the code as-is here:

https://github.com/miracle2k/jinja2/compare/90-matcher

miracle2k avatar Jan 25 '12 17:01 miracle2k