-
Notifications
You must be signed in to change notification settings - Fork 419
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
each* string functions #91
Comments
I think this could be useful, especially with multi-arg support. Would you see a version of this wherein the templates the user could simply do |
I believe that would either require reflection or a big switch which would in turn call the actual function. It could work, but in my experience explicit function calls work better in this case. Since there is a pattern, it's really easy to guess the behavior. But yeah, that could work. |
@sagikazarmark What would the template functions be, what would they work on, and why those things? I'm trying to understand the end user need and what would be solved. The technique looks interesting and I could see uses. Just trying to understand why and how to bake it in here. The why and what it solves is important. |
I came looking for something like this. Actually I wanted to run |
@mattfarina sorry, but I don't remember what the use case was. I guess the idea is that you can output a list of strings, but apply some filters to it first? Unfortunately I rarely use templates these days. :\ |
Recently I needed to work with string slices in templates and apply various functions to each element (title, lower, trim, etc). I wanted to avoid using loops and assignments, so I came up with eachTitle, eachLower, eachTrim, etc functions.
It's quite simple really:
Usage:
Do you think it would fit into this package? I could extend it into a solution that would work with functions that have more than one parameter.
The text was updated successfully, but these errors were encountered: