﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
6799	Update to truncate words methods to make them more callable	bret	adamfast	"In certain situations, the functionality of the truncate_words and truncate_html_words functions are needed, but the default action of appending an ellipsis is not desirable.

Currently, truncate_words and truncate_html_words functions only accept a single parameter -- an int representing the number of words to allow.

If these functions replace the hard coded ellipsis with a value passed in as a parameter, it would increase their usefulness.
The attached patch does this by adding an end_text parameter with a default value of '...'.  If the function is called without being passed the end_text parameter, it will function as it always has.

Adding this parameter would allow a user to easily utilize the contributed truncating code in his own code.

An example:

{{{
from django.contrib.utils.text import truncate_html_words
class Entry(models.Model):
    body = models.TextField()

    def truncated(self):
        return truncate_html_words(self.body, 100, '<a href=""' + self.get_absolute_url + '"">Continue...</a>')

    def get_absolute_url(self):
        ....
}}}


object.truncated could then be used in a template in place of object.body|truncatewords_html.

"		closed	Contrib apps	dev		fixed			Ready for checkin	1	0	0	0	0	0
