diff options
author | Kristi Tsukida <kristi.dev@gmail.com> | 2012-07-10 13:25:38 -0700 |
---|---|---|
committer | Kristi Tsukida <kristi.dev@gmail.com> | 2012-07-10 13:25:38 -0700 |
commit | 15605a84be45f368cc93b447da8e9c70ef84bb0b (patch) | |
tree | 2c1eeb528bee4562db6f188a30130adf04afaf25 | |
parent | 6327f79efd5b48fd47a785feb77467b52e62ae32 (diff) | |
download | jinja2-15605a84be45f368cc93b447da8e9c70ef84bb0b.tar.gz |
lstrip spaces (but not newlines) from block tags
-rw-r--r-- | jinja2/lexer.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/jinja2/lexer.py b/jinja2/lexer.py index 69865d0..917f072 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<raw_begin>(?:\s*%s\-|%s)\s*raw\s*(?:\-%s\s*|%s))' % ( + [r'(?P<raw_begin>(?:\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), |