Summary: Replace old-style wordwrap custom tag with {% filter wordwrap %}

- Legacy-Id: 8965
This commit is contained in:
Ole Laursen 2015-02-04 12:48:47 +00:00
parent b608626729
commit d61ed824cd
2 changed files with 3 additions and 33 deletions

View file

@ -527,36 +527,6 @@ def consensus(doc):
else:
return "Unknown"
# The function and class below provides a tag version of the builtin wordwrap filter
# https://djangosnippets.org/snippets/134/
@register.tag
def wordwrap(parser, token):
"""
This is a tag version of the Django builtin 'wordwrap' filter. This is useful
if you need to wrap a combination of fixed template text and template variables.
Usage:
{% wordwrap 80 %}
some really long text here, including template variable expansion, etc.
{% endwordwrap %}
"""
try:
tag_name, len = token.split_contents()
except ValueError:
raise template.TemplateSyntaxError, "The wordwrap tag requires exactly one argument: width."
nodelist = parser.parse(('endwordwrap',))
parser.delete_first_token()
return WordWrapNode(nodelist, len)
class WordWrapNode(template.Node):
def __init__(self, nodelist, len):
self.nodelist = nodelist
self.len = len
def render(self, context):
return wrap(str(self.nodelist.render(context)), int(self.len))
@register.filter
def pos_to_label(text):
"""Return a valid Bootstrap3 label type for a ballot position."""

View file

@ -6,10 +6,10 @@ Cc: {{ cc_email }}
Dear {{ to_name }}:
{% wordwrap 80 %}
{% filter wordwrap:80 %}
An IPR disclosure that pertains to your {{ doc_info }} was submitted to the IETF Secretariat on {{ ipr.submitted_date|date:"Y-m-d" }} and has been posted on the "IETF Page of Intellectual Property Rights Disclosures" (https://datatracker.ietf.org/ipr/{{ ipr.pk }}/). The title of the IPR disclosure is "{{ ipr.title }}"
{% endwordwrap %}
{% endfilter %}
Thank you
IETF Secretariat
IETF Secretariat