class Truncator(SimpleLazyObject):
Method | __init__ |
Pass in a callable that returns the object to be wrapped. |
Method | _text_chars |
Truncate a string after a certain number of chars. |
Method | _text_words |
Truncate a string after a certain number of words. |
Method | _truncate_html |
Truncate HTML to a certain number of chars (not counting tags and comments), or, if words is True, then to a certain number of words. Close opened tags if they were correctly closed in the given HTML. |
Method | add_truncation_text |
Undocumented |
Method | chars |
Return the text truncated to be no longer than the specified number of characters. |
Method | words |
Truncate a string after a certain number of words. truncate specifies what should be used to notify that the string has been truncated, defaulting to ellipsis. |
Inherited from SimpleLazyObject
:
Method | __copy__ |
Undocumented |
Method | __deepcopy__ |
Undocumented |
Method | __repr__ |
Undocumented |
Method | _setup |
Must be implemented by subclasses to initialize the wrapped object. |
Instance Variable | _wrapped |
Undocumented |
Inherited from LazyObject
(via SimpleLazyObject
):
Method | __delattr__ |
Undocumented |
Method | __reduce__ |
Undocumented |
Method | __setattr__ |
Undocumented |
Class Variable | __bool__ |
Undocumented |
Class Variable | __bytes__ |
Undocumented |
Class Variable | __class__ |
Undocumented |
Class Variable | __contains__ |
Undocumented |
Class Variable | __delitem__ |
Undocumented |
Class Variable | __dir__ |
Undocumented |
Class Variable | __eq__ |
Undocumented |
Class Variable | __getattr__ |
Undocumented |
Class Variable | __getitem__ |
Undocumented |
Class Variable | __gt__ |
Undocumented |
Class Variable | __hash__ |
Undocumented |
Class Variable | __iter__ |
Undocumented |
Class Variable | __len__ |
Undocumented |
Class Variable | __lt__ |
Undocumented |
Class Variable | __ne__ |
Undocumented |
Class Variable | __setitem__ |
Undocumented |
Class Variable | __str__ |
Undocumented |
Pass in a callable that returns the object to be wrapped.
If copies are made of the resulting SimpleLazyObject, which can happen in various circumstances within Django, then you must ensure that the callable can be safely run more than once and will return the same value.
Truncate a string after a certain number of words.
Strip newlines in the string.
Truncate HTML to a certain number of chars (not counting tags and comments), or, if words is True, then to a certain number of words. Close opened tags if they were correctly closed in the given HTML.
Preserve newlines in the HTML.