class Truncator(SimpleLazyObject): (source)
An object used to truncate text, either by characters or words.
Method | __init__ |
Pass in a callable that returns the object to be wrapped. |
Method | add |
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. |
Method | _text |
Truncate a string after a certain number of chars. |
Method | _text |
Truncate a string after a certain number of words. |
Method | _truncate |
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. |
Inherited from SimpleLazyObject
:
Method | __copy__ |
Undocumented |
Method | __deepcopy__ |
Undocumented |
Method | __radd__ |
Undocumented |
Method | __repr__ |
Undocumented |
Class Variable | __add__ |
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 | __getattribute__ |
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.
Return the text truncated to be no longer than the specified number of characters. `truncate` specifies what should be used to notify that the string has been truncated, defaulting to a translatable string of an ellipsis.
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.