From: Kristi Tsukida Date: Tue, 10 Jul 2012 20:25:38 +0000 (-0700) Subject: lstrip spaces (but not newlines) from block tags X-Git-Tag: 2.7~48^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=15605a84be45f368cc93b447da8e9c70ef84bb0b;p=thirdparty%2Fjinja.git lstrip spaces (but not newlines) from block tags --- diff --git a/jinja2/lexer.py b/jinja2/lexer.py index 69865d08..917f0729 100644 --- a/jinja2/lexer.py +++ b/jinja2/lexer.py @@ -424,6 +424,8 @@ class Lexer(object): # block suffix if trimming is enabled block_suffix_re = environment.trim_blocks and '\\n?' or '' + # TODO hook environment setting + block_prefix_re = True and '[ \\t]*' or '' self.newline_sequence = environment.newline_sequence @@ -432,8 +434,9 @@ class Lexer(object): 'root': [ # directives (c('(.*?)(?:%s)' % '|'.join( - [r'(?P(?:\s*%s\-|%s)\s*raw\s*(?:\-%s\s*|%s))' % ( + [r'(?P(?:\s*%s\-|%s%s)\s*raw\s*(?:\-%s\s*|%s))' % ( e(environment.block_start_string), + block_prefix_re, e(environment.block_start_string), e(environment.block_end_string), e(environment.block_end_string) @@ -470,8 +473,9 @@ class Lexer(object): ] + tag_rules, # raw block TOKEN_RAW_BEGIN: [ - (c('(.*?)((?:\s*%s\-|%s)\s*endraw\s*(?:\-%s\s*|%s%s))' % ( + (c('(.*?)((?:\s*%s\-|%s%s)\s*endraw\s*(?:\-%s\s*|%s%s))' % ( e(environment.block_start_string), + block_prefix_re, e(environment.block_start_string), e(environment.block_end_string), e(environment.block_end_string),