#1919: filter truncatewords wipes newlines from string, so not chainable with
markup filters
----------------------+-----------------------------------------------------
Reporter: derelm | Owner: mtredinnick
Status: new | Component: Template system
Version: SVN | Resolution:
Keywords: | Stage: Accepted
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 1
----------------------+-----------------------------------------------------
Changes (by mtredinnick):
* owner: adrian => mtredinnick
* needs_better_patch: 0 => 1
* stage: Ready for checkin => Accepted
Comment:
I'm going to bounce this patch back for improvement (I'm just doing a
"check in the obviously correct" pass at the moment, so I don't want to
stop and fix it right now).
I think you can get away with just one call to re.split() without the
subsequent re.search() every time through the list. After the call to
re.split(), every second element in the returned list is the whitespace.
So you can iterate through the "words" list (in the patch's terminology)
two elements at a time: the first one will be a word, the second the
whitespace. That avoids the need to call whitespace_re.search() each time.
It will improve performance a bit (and reduce the line count, too, I
suspect).
A test of this would be nice, too, since it's not immediately clear that
it works 100%.
--
Ticket URL: <http://code.djangoproject.com/ticket/1919#comment:5>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---