You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
django have template tags linebreaks and linebreaksbr.
I use TextField for store my post. in template {{ post.content|safe|bbcode }}, if I input many enter for linebreak, bbcode template tag convert it to too many tag.
so, I wish bbcode template tag can parse it like linebreaks, not linebreaksbr
thanks
The text was updated successfully, but these errors were encountered:
@register.filter("linebreaks", is_safe=True, needs_autoescape=True)
@stringfilter
def linebreaks_filter(value, autoescape=True):
"""
Replaces line breaks in plain text with appropriate HTML; a single
newline becomes an HTML line break (``<br />``) and a new line
followed by a blank line becomes a paragraph break (``</p>``).
"""
autoescape = autoescape and not isinstance(value, SafeData)
return mark_safe(linebreaks(value, autoescape))
@register.filter(is_safe=True, needs_autoescape=True)
@stringfilter
def linebreaksbr(value, autoescape=True):
"""
Converts all newlines in a piece of plain text to HTML line breaks
(``<br />``).
"""
autoescape = autoescape and not isinstance(value, SafeData)
value = normalize_newlines(value)
if autoescape:
value = escape(value)
return mark_safe(value.replace('\n', '<br />'))
django have template tags linebreaks and linebreaksbr.
I use TextField for store my post. in template {{ post.content|safe|bbcode }}, if I input many enter for linebreak, bbcode template tag convert it to too many
tag.
so, I wish bbcode template tag can parse it like linebreaks, not linebreaksbr
thanks
The text was updated successfully, but these errors were encountered: