Code

Ticket #14502: 14502-no-customizable-end-tag.patch

File 14502-no-customizable-end-tag.patch, 3.4 KB (added by aaugustin, 23 months ago)
  • django/template/base.py

    diff --git a/django/template/base.py b/django/template/base.py
    index 9b2404c..87ad6f6 100644
    a b class Lexer(object): 
    210210            # hard-coded the 2s here for performance. And it's not like 
    211211            # the TAG_START values are going to change anytime, anyway. 
    212212            block_content = token_string[2:-2].strip() 
    213             if self.verbatim and block_content == self.verbatim: 
     213            if self.verbatim and block_content == 'endverbatim': 
    214214                self.verbatim = False 
    215215        if in_tag and not self.verbatim: 
    216216            if token_string.startswith(VARIABLE_TAG_START): 
    217217                token = Token(TOKEN_VAR, token_string[2:-2].strip()) 
    218218            elif token_string.startswith(BLOCK_TAG_START): 
    219                 if block_content.startswith('verbatim'): 
    220                     bits = block_content.split(' ', 1) 
    221                     if bits[0] == 'verbatim': 
    222                         if len(bits) > 1: 
    223                             self.verbatim = bits[1] 
    224                         else: 
    225                             self.verbatim = 'endverbatim' 
     219                if block_content == 'verbatim': 
     220                    self.verbatim = True 
    226221                token = Token(TOKEN_BLOCK, block_content) 
    227222            elif token_string.startswith(COMMENT_TAG_START): 
    228223                content = '' 
  • django/template/defaulttags.py

    diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py
    index 3073b41..9fc2522 100644
    a b def verbatim(parser, token): 
    12891289        {% verbatim %} 
    12901290            {% don't process this %} 
    12911291        {% endverbatim %} 
    1292  
    1293     You can also specify an alternate closing tag:: 
    1294  
    1295         {% verbatim -- %} 
    1296             ... 
    1297         {% -- %} 
    12981292    """ 
    1299     bits = token.contents.split(' ', 1) 
    1300     if len(bits) > 1: 
    1301         closing_tag = bits[1] 
    1302     else: 
    1303         closing_tag = 'endverbatim' 
    1304     nodelist = parser.parse((closing_tag,)) 
     1293    nodelist = parser.parse(('endverbatim',)) 
    13051294    parser.delete_first_token() 
    13061295    return VerbatimNode(nodelist.render(Context())) 
    13071296 
  • docs/ref/templates/builtins.txt

    diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt
    index af9004b..95889f4 100644
    a b Django's syntax. For example:: 
    10561056        {{if dying}}Still alive.{{/if}} 
    10571057    {% endverbatim %} 
    10581058 
    1059 You can also specify an alternate closing tag:: 
    1060  
    1061     {% verbatim finished %} 
    1062         The verbatim tag looks like this: 
    1063         {% verbatim %}{% endverbatim %} 
    1064     {% finished %} 
    1065  
    10661059.. templatetag:: widthratio 
    10671060 
    10681061widthratio 
  • tests/regressiontests/templates/tests.py

    diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py
    index 957ad2b..ce39d85 100644
    a b class Templates(unittest.TestCase): 
    16231623            'verbatim-tag03': ("{% verbatim %}It's the {% verbatim %} tag{% endverbatim %}", {}, "It's the {% verbatim %} tag"), 
    16241624            'verbatim-tag04': ('{% verbatim %}{% verbatim %}{% endverbatim %}{% endverbatim %}', {}, template.TemplateSyntaxError), 
    16251625            'verbatim-tag05': ('{% verbatim %}{% endverbatim %}{% verbatim %}{% endverbatim %}', {}, ''), 
    1626             'verbatim-tag06': ("{% verbatim -- %}Don't {% endverbatim %} just yet{% -- %}", {}, "Don't {% endverbatim %} just yet"), 
    16271626        } 
    16281627        return tests 
    16291628