Support for common python string functions
It should be possible to call common python string functions (like split, partition etc.) from the Jinja2 templates. Like this:
{% set strings=text.split(' ') %}
If is it that you say : https://docs.python.org/fr/3/library/stdtypes.html#str
I will work on it for Hacktoberfest :)
Yes, exactly. Thanks! But before you start, lets discuss the exact set of methods to implement.
Is it possible to first implement :
- ~
str.capitalize()~ - [ ]
str.center(width[, fillchar]) - [ ]
str.count(sub[, start[, end]]) - [ ]
str.endswith(suffix[, start[, end]]) - [ ]
str.find(sub[, start[, end]]) - [ ]
str.index(sub[, start[, end]]) - [ ]
str.isalnum() - [ ]
str.isascii() - [ ]
str.isnumeric() - [ ]
str.islower() - [ ]
str.isupper() - ~
str.lower()~ - [ ]
str.replace(old, new[, count]) - [ ]
str.split(sep=None, maxsplit=-1) - [ ]
str.splitlines([keepends]) - [ ]
str.startswith(prefix[, start[, end]]) - [ ]
str.strip([chars]) - ~
str.upper()~
Is it too much ? :)
More over, For my personal dev, I will add a Dockerfile for compilation, do you want it too ?
Good coding day
For my personal dev, I will add a Dockerfile for compilation, do you want it too ?
I'm using Windows environment for development so Docker isn't my choice...
Is it too much ?
That's a good list. One thing I care about: there is implementation of some of this methods as a filters/testers (ex. https://github.com/jinja2cpp/Jinja2Cpp/blob/master/src/string_converter_filter.cpp ) So, there should be a way to reuse this implementation somehow.
Hi,
For the Dockerfile, perhaps, just put it in wiki to prevent misunderstanding :)
Yes, I have see that file :) Thank you
Hey,
Even if I have not ended that PR before the end of Hacktoberfest, I will finish it ;)
Have a good coding day
Thank you!
Can you share your approach in handling user-callable for strings? Looks like I need to do the same for MapAdapter. #178