Ticket #2016: 0001-Moves-the-argument-matching-to-a-separate-function.diff

File 0001-Moves-the-argument-matching-to-a-separate-function.diff, 1.1 KB (added by marcusf, 6 years ago)
  • django/template/__init__.py

    diff --git a/django/template/__init__.py b/django/template/__init__.py
    index 5493e5b..14eea5c 100644
    a b class VariableNode(Node): 
    830830            return ''
    831831        return _render_value_in_context(output, context)
    832832
    833 def generic_tag_compiler(params, defaults, name, node_class, parser, token):
    834     "Returns a template.Node subclass."
    835     bits = token.split_contents()[1:]
     833def match_number_of_arguments(bits, params, defaults, name):
    836834    bmax = len(params)
    837835    def_len = defaults and len(defaults) or 0
    838836    bmin = bmax - def_len
    def generic_tag_compiler(params, defaults, name, node_class, parser, token): 
    842840        else:
    843841            message = "%s takes between %s and %s arguments" % (name, bmin, bmax)
    844842        raise TemplateSyntaxError(message)
     843
     844def generic_tag_compiler(params, defaults, name, node_class, parser, token):
     845    "Returns a template.Node subclass."
     846    bits = token.split_contents()[1:]
     847    match_number_of_arguments(bits, params, defaults, name)
    845848    return node_class(bits)
    846849
    847850class Library(object):
Back to Top