Slice filter

1
2
3
@register.filter
def slice(s, delimiter=' '):
    return s.slice(delimiter)

More like this

  1. truncatestring filter by pigletto 4 years, 2 months ago
  2. Humanize lists of strings in templates by ChipX86 5 years, 11 months ago
  3. Akismet Webservice by sneeu 6 years, 2 months ago
  4. a simple tag with context by dsblank 3 years, 5 months ago
  5. Generate Javascript-Safe string in template by Spike^ekipS 6 years, 2 months ago

Comments

jcroft (on March 6, 2007):

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.

#

jacobian (on March 6, 2007):

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.

#

whiskybar (on March 7, 2007):

Did you mean split?

#

sneeu (on March 14, 2007):

Ah yes, sorry - it should be called split.

#

(Forgotten your password?)