Support the autoescape block
This commit is contained in:
parent
2f9cca0b75
commit
fb82cba2c8
@ -78,6 +78,9 @@ def parse_block(ast):
|
||||
def parse_block_pair(ast):
|
||||
block_name = ast['start']['name']
|
||||
|
||||
if block_name == 'autoescape':
|
||||
return parse_block_autoescape(ast)
|
||||
|
||||
if block_name == 'block':
|
||||
return parse_block_block(ast)
|
||||
|
||||
@ -98,6 +101,20 @@ def parse_block_pair(ast):
|
||||
|
||||
return None
|
||||
|
||||
def parse_block_autoescape(ast):
|
||||
return nodes.Scope(
|
||||
[nodes.ScopedEvalContextModifier(
|
||||
[nodes.Keyword(
|
||||
'autoescape',
|
||||
parse_variable(ast['start']['parameters'][0]['value']),
|
||||
lineno=lineno_from_parseinfo(ast['start']['parameters'][0]['parseinfo'])
|
||||
)],
|
||||
parse(ast['contents']),
|
||||
lineno=lineno_from_parseinfo(ast['parseinfo'])
|
||||
)],
|
||||
lineno=lineno_from_parseinfo(ast['parseinfo'])
|
||||
)
|
||||
|
||||
def parse_block_block(ast):
|
||||
name = parse_variable(ast['start']['parameters'][0]['value']).name
|
||||
scoped = False
|
||||
|
||||
@ -49,4 +49,11 @@ across lines #}
|
||||
<ul class="submenu">{{ loop(item.children) }}</ul>
|
||||
{%- endif %}</li>
|
||||
{%- endfor %}
|
||||
</ul>
|
||||
</ul>
|
||||
{% autoescape true %}
|
||||
Autoescaping is active within this block
|
||||
{% endautoescape %}
|
||||
|
||||
{% autoescape false %}
|
||||
Autoescaping is inactive within this block
|
||||
{% endautoescape %}
|
||||
Loading…
Reference in New Issue
Block a user