Permalink
Browse files

lstrip spaces (but not newlines) from block tags

  • Loading branch information...
1 parent 6327f79 commit 15605a84be45f368cc93b447da8e9c70ef84bb0b @kristi committed Jul 10, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 jinja2/lexer.py
View
@@ -424,6 +424,8 @@ def __init__(self, environment):
# 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 @@ def __init__(self, environment):
'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 @@ def __init__(self, environment):
] + 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),

0 comments on commit 15605a8

Please sign in to comment.