1 2 3 | @register.filter
def slice(s, delimiter=' '):
return s.slice(delimiter)
|
More like this
- Word-boundary-aware string truncation template filter by josho 3 years ago
- Generate Javascript-Safe string in template by Spike^ekipS 5 years, 2 months ago
- truncatestring filter by pigletto 3 years, 2 months ago
- Split a string to a list and add to select options by xuqingkuang 3 years, 1 month ago
- JSON-compatible query filter specification by mhalle 4 years, 1 month ago
Comments
The name "slice" conflicts with the built-in "slice" filter. I'd definitely recommend anyone who use this change the name, or you could be headed for troubled.
#
Yeah, I'm not sure this works at all... strings don't have a "slice" method, so likely this doesn't do anything except throw an error.
#
Did you mean split?
#
Ah yes, sorry - it should be called split.
#