Fix variables containing multiple words

This commit is contained in:
William Vandervalk 2022-09-26 13:11:58 -04:00
parent 0ace5e3b02
commit b2dba02edd
4 changed files with 7667 additions and 7684 deletions

View file

@ -38,8 +38,8 @@ module.exports = grammar({
_expression: $ => seq("{{", optional($._ws), $.variable, optional($._ws), "}}"),
variable: $ => seq($.variable_name, repeat(seq("|", $.filter))),
// Django variables cannot start with an "_", can contain one or two words separated by a "."
variable_name: $ => seq(repeat1(/[A-Za-z]/), optional($._word), optional(seq(".", $._word))),
// Django variables cannot start with an "_", can contain one or more words separated by a "."
variable_name: $ => seq(repeat1(/[A-Za-z]/), optional($._word), repeat(seq(".", $._word))),
filter: $ => seq($.filter_name, optional(seq(":", choice($.filter_argument, $._quoted_filter_argument)))),
filter_name: $ => $._word,

View file

@ -325,25 +325,20 @@
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "."
},
{
"type": "SYMBOL",
"name": "_word"
}
]
},
{
"type": "BLANK"
}
]
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "."
},
{
"type": "SYMBOL",
"name": "_word"
}
]
}
}
]
},

15311
src/parser.c

File diff suppressed because it is too large Load diff

View file

@ -4,6 +4,7 @@ variable
<html>
{{ variable }}
{{ variable.item1.item2 }}
{{ variable|filter }}
{{ variable|filter:argument }}
{{ variable|filter:argument.item1.item2 }}
@ -16,6 +17,8 @@ variable
(template
(content)
(variable
(variable_name))
(variable
(variable_name))
(variable