Support boolean literals

This will transparently convert them into an actual boolean which
should skip any variable-like parsing that would otherwise be done.
This commit is contained in:
Kevin Brown 2020-05-08 08:29:24 -04:00 committed by Kevin
parent e9e098cc48
commit 5fdbdec06c
2 changed files with 9 additions and 2 deletions

View File

@ -76,7 +76,7 @@ variable_close
variable_identifier
=
( IDENTIFIER | LITERAL )
( LITERAL | IDENTIFIER )
{ variable_accessor }*
;
@ -150,7 +150,7 @@ content = !(block_open | variable_open | comment_open) CHAR ;
LITERAL
=
STRING_LITERAL | NUMBER_LITERAL
STRING_LITERAL | NUMBER_LITERAL | BOOLEAN_LITERAL
;
INTEGER_LITERAL
@ -180,6 +180,11 @@ STRING_LITERAL_DOUBLE_QUOTE
'"' { !'"' /./ }* '"'
;
BOOLEAN_LITERAL
=
(("true" | "True") @:`True`) | (("false" | "False") @:`False`)
;
IDENTIFIER
=
/[a-zA-Z_][a-zA-Z0-9_]*/

View File

@ -11,5 +11,7 @@ across lines #}
{% raw %}
{% block %}fake content{{ fake vars }}
{% endraw %}
{% if False %}
{{ '{{' }}
{% endif %}
{% trans user=user.username %}Hello, {{ user }}!{% endtrans %}