-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Add template funcs countwords and countrunes #1440
Add template funcs countwords and countrunes #1440
Conversation
@@ -460,18 +524,25 @@ e.g. | |||
* `{{substr "BatMan" 0 -3}}` → "Bat" | |||
* `{{substr "BatMan" 3 3}}` → "Man" | |||
|
|||
|
|||
*** |
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.
What's all these asterisks?
I revisited the functions and aspects @bep mentioned in his comments. To support CJK languages I added the Both Usually all functions have a test case to check if they work properly. Since both template functions use the same code as A quick look at them showed that they used sample content defined in constants. I used them to test my template functions manually and compared the result with the exptected values in the existing test functions and got the same results. So, should I add testing functions anyway? Finally, I removed the asterisks that were initially added as spacers between the functions to get a better overview. |
Is this PR in a mergable state or is something missing? |
It is mergable -- but I wonder: What is the use case for this? When do you need to count words? |
I thought especially about external ressources that you can fetch with |
Is there any interest for such template functions or should I close this issue? /cc @bep |
@digitalcraftsman @bep I'm fine with this code. I'm not sure what the valid use is for it though. If anyone has one, happy to merge. I'd be surprised if someone doesn't have one for it and it doesn't really add any weight to have this functionality. |
I was going to say documentation, but I notice @digitalcraftsman has supplied perfect docs for this, so yes -- I don't need this, but I'm sure someone will. I'm fine with this. |
merged as dfa34af |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Takes any type, tries to conver it into a string and returns the total number of words.