Ejemplo n.º 1
0
def urlize_hashtags(value):
    """
	Converts hashtags in plain text into clickable links.
	For example::
		{{ value|urlize_hashtags }}
	If value is "This is a #test.", the output will be "This is a
	<a href="[reversed url for hashtagged_item_list(request, hashtag='test')]">#test</a>.".
	Note that if ``urlize_hashtags`` is applied to text that already contains
	HTML markup, things won't work as expected. Prefer apply this filter to
	plain text.
	"""
    from hashtags.utils import urlize_hashtags
    return mark_safe(urlize_hashtags(value))
Ejemplo n.º 2
0
def urlize_hashtags(value):
    """
    Converts hashtags in plain text into clickable links.

    For example::

      {{ value|urlize_hashtags }}

    If value is "This is a #test.", the output will be "This is a
    <a href="[reversed url for hashtagged_item_list(request, hashtag='test')]">#test</a>.".

    Note that if ``urlize_hashtags`` is applied to text that already contains
    HTML markup, things won't work as expected. Prefer apply this filter to
    plain text.
    """
    from hashtags.utils import urlize_hashtags
    return mark_safe(urlize_hashtags(value))
Ejemplo n.º 3
0
def urlize_and_track_hashtags(value, object_to_track):
    """
    Works like ``urlize_hashtags`` but you can pass a object parameter to
    link/relate hashtags on text with the object in question.

    Usage example::

        {{ value|urlize_and_track_hashtags:object_to_track }}

    Real world example::

        {{ flatpage.content|urlize_and_track_hashtags:flatpage }}

    **Important**: ``urlize_and_track_hashtags`` doesn't works properly if your
    object has two fields with hashtags to be tracked. Use the signals below if
    you want this feature or if you want hashtags updated on ``post_save``
    signal instead on template rendering.
    """
    link_hashtags_to_model(value, object_to_track)
    return mark_safe(urlize_hashtags(value))
Ejemplo n.º 4
0
def urlize_and_track_hashtags(value, object_to_track):
    """
    Works like ``urlize_hashtags`` but you can pass a object parameter to
    link/relate hashtags on text with the object in question.

    Usage example::

        {{ value|urlize_and_track_hashtags:object_to_track }}

    Real world example::

        {{ flatpage.content|urlize_and_track_hashtags:flatpage }}

    **Important**: ``urlize_and_track_hashtags`` doesn't works property if your
    object has two fields with hashtags to be tracked. Use the signals below if
    you want this feature or if you want hashtags updated on ``post_save``
    signal instead on template rendering.
    """
    link_hashtags_to_model(value, object_to_track)
    return mark_safe(urlize_hashtags(value))