fix include
This commit is contained in:
1 parent
f93938c277
commit
0caa8c104b
5 files changed
+44886
-44032
No files matched your search
+22
-4
@@ -527,7 +527,7 @@ const django = grammar({
|
|||||||
seq(
|
seq(
|
||||||
$._bt_option,
|
$._bt_option,
|
||||||
choice(
|
choice(
|
||||||
seq(part("with"), $._translate_kwargs),
|
seq(part("with"), $._tag_kwargs),
|
||||||
part("context", $.filtered_value),
|
part("context", $.filtered_value),
|
||||||
part("trimmed"),
|
part("trimmed"),
|
||||||
part("asvar", field("variable", $.identifier)),
|
part("asvar", field("variable", $.identifier)),
|
||||||
@@ -542,8 +542,13 @@ const django = grammar({
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
_translate_body: ($) => repeat1(choice($.content, $.template_variable)),
|
_translate_body: ($) => repeat1(choice($.content, $.template_variable)),
|
||||||
/** The "with" option of blocktranslate takes at least one of these. */
|
/**
|
||||||
_translate_kwargs: ($) =>
|
* The "with" option of blocktranslate and of include takes at least one of
|
||||||
|
* these. Django lets a name repeat here — token_kwargs builds a dict and
|
||||||
|
* the later value wins — so unlike a simple_tag's arguments they are not
|
||||||
|
* guarded.
|
||||||
|
*/
|
||||||
|
_tag_kwargs: ($) =>
|
||||||
repeat1(
|
repeat1(
|
||||||
part(seq(field("variable", $.identifier), "=", $.filtered_value)),
|
part(seq(field("variable", $.identifier), "=", $.filtered_value)),
|
||||||
),
|
),
|
||||||
@@ -674,7 +679,20 @@ const django = grammar({
|
|||||||
optional(seq(block("else"), optional($.template))),
|
optional(seq(block("else"), optional($.template))),
|
||||||
block("endifchanged"),
|
block("endifchanged"),
|
||||||
),
|
),
|
||||||
include: ($) => block("include", part($.filtered_value)),
|
/**
|
||||||
|
* do_include takes "with" and "only" in either order and refuses one it has
|
||||||
|
* already been given, and "with" needs at least one argument. It calls
|
||||||
|
* token_kwargs with support_legacy=False, so "{% include "t" with a as b %}"
|
||||||
|
* is an error here as it is there, unlike the same clause in "{% with %}".
|
||||||
|
*/
|
||||||
|
include: ($) =>
|
||||||
|
block(
|
||||||
|
"include",
|
||||||
|
part($.filtered_value),
|
||||||
|
optional(
|
||||||
|
arrangements([seq(part("with"), $._tag_kwargs), part("only")]),
|
||||||
|
),
|
||||||
|
),
|
||||||
/** django.templatetags.i18n. The language tag takes the one argument. */
|
/** django.templatetags.i18n. The language tag takes the one argument. */
|
||||||
language_group: ($) =>
|
language_group: ($) =>
|
||||||
seq(
|
seq(
|
||||||
|
|||||||
+130
-2
@@ -1980,7 +1980,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "_translate_kwargs"
|
"name": "_tag_kwargs"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -2125,7 +2125,7 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"_translate_kwargs": {
|
"_tag_kwargs": {
|
||||||
"type": "REPEAT1",
|
"type": "REPEAT1",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
@@ -4695,6 +4695,134 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[ \\t\\r\\n]+"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "with"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_tag_kwargs"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[ \\t\\r\\n]+"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "with"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_tag_kwargs"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[ \\t\\r\\n]+"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "only"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[ \\t\\r\\n]+"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "only"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[ \\t\\r\\n]+"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "only"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "[ \\t\\r\\n]+"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "with"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_tag_kwargs"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "BLANK"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
|
|||||||
+15
-1
@@ -1377,10 +1377,20 @@
|
|||||||
"named": false
|
"named": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"variable": {
|
||||||
|
"multiple": true,
|
||||||
|
"required": false,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "identifier",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"children": {
|
"children": {
|
||||||
"multiple": false,
|
"multiple": true,
|
||||||
"required": true,
|
"required": true,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
{
|
||||||
@@ -2714,6 +2724,10 @@
|
|||||||
"type": "on",
|
"type": "on",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "only",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "openblock",
|
"type": "openblock",
|
||||||
"named": false
|
"named": false
|
||||||
|
|||||||
+44494
-44025
File diff suppressed because it is too large.
Load diff
@@ -31,3 +31,228 @@ Include With Variable
|
|||||||
(variable_attribute
|
(variable_attribute
|
||||||
(identifier)))))
|
(identifier)))))
|
||||||
(content))
|
(content))
|
||||||
|
|
||||||
|
==================
|
||||||
|
Include With A Filtered Name
|
||||||
|
==================
|
||||||
|
|
||||||
|
{% include "t.html"|upper %}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(template
|
||||||
|
(content)
|
||||||
|
(include
|
||||||
|
(filtered_value
|
||||||
|
(value
|
||||||
|
(literal
|
||||||
|
(string)))
|
||||||
|
(filter_expression
|
||||||
|
(filter))))
|
||||||
|
(content))
|
||||||
|
|
||||||
|
==================
|
||||||
|
Include Only
|
||||||
|
==================
|
||||||
|
|
||||||
|
{% include "t.html" only %}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(template
|
||||||
|
(content)
|
||||||
|
(include
|
||||||
|
(filtered_value
|
||||||
|
(value
|
||||||
|
(literal
|
||||||
|
(string)))))
|
||||||
|
(content))
|
||||||
|
|
||||||
|
==================
|
||||||
|
Include With Context
|
||||||
|
==================
|
||||||
|
|
||||||
|
{% include "t.html" with a=1 %}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(template
|
||||||
|
(content)
|
||||||
|
(include
|
||||||
|
(filtered_value
|
||||||
|
(value
|
||||||
|
(literal
|
||||||
|
(string))))
|
||||||
|
variable: (identifier)
|
||||||
|
(filtered_value
|
||||||
|
(value
|
||||||
|
(literal
|
||||||
|
(number)))))
|
||||||
|
(content))
|
||||||
|
|
||||||
|
==================
|
||||||
|
Include With Several Bindings
|
||||||
|
==================
|
||||||
|
|
||||||
|
{% include "t.html" with a=1 b=2 %}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(template
|
||||||
|
(content)
|
||||||
|
(include
|
||||||
|
(filtered_value
|
||||||
|
(value
|
||||||
|
(literal
|
||||||
|
(string))))
|
||||||
|
variable: (identifier)
|
||||||
|
(filtered_value
|
||||||
|
(value
|
||||||
|
(literal
|
||||||
|
(number))))
|
||||||
|
variable: (identifier)
|
||||||
|
(filtered_value
|
||||||
|
(value
|
||||||
|
(literal
|
||||||
|
(number)))))
|
||||||
|
(content))
|
||||||
|
|
||||||
|
==================
|
||||||
|
Include With Context And Only
|
||||||
|
==================
|
||||||
|
|
||||||
|
{% include "t.html" with a=1 only %}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(template
|
||||||
|
(content)
|
||||||
|
(include
|
||||||
|
(filtered_value
|
||||||
|
(value
|
||||||
|
(literal
|
||||||
|
(string))))
|
||||||
|
variable: (identifier)
|
||||||
|
(filtered_value
|
||||||
|
(value
|
||||||
|
(literal
|
||||||
|
(number)))))
|
||||||
|
(content))
|
||||||
|
|
||||||
|
==================
|
||||||
|
Include With Only Before With
|
||||||
|
==================
|
||||||
|
|
||||||
|
{% include "t.html" only with a=1 %}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(template
|
||||||
|
(content)
|
||||||
|
(include
|
||||||
|
(filtered_value
|
||||||
|
(value
|
||||||
|
(literal
|
||||||
|
(string))))
|
||||||
|
variable: (identifier)
|
||||||
|
(filtered_value
|
||||||
|
(value
|
||||||
|
(literal
|
||||||
|
(number)))))
|
||||||
|
(content))
|
||||||
|
|
||||||
|
==================
|
||||||
|
Include With A Repeated Binding
|
||||||
|
==================
|
||||||
|
|
||||||
|
{% include "t.html" with a=1 a=2 %}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(template
|
||||||
|
(content)
|
||||||
|
(include
|
||||||
|
(filtered_value
|
||||||
|
(value
|
||||||
|
(literal
|
||||||
|
(string))))
|
||||||
|
variable: (identifier)
|
||||||
|
(filtered_value
|
||||||
|
(value
|
||||||
|
(literal
|
||||||
|
(number))))
|
||||||
|
variable: (identifier)
|
||||||
|
(filtered_value
|
||||||
|
(value
|
||||||
|
(literal
|
||||||
|
(number)))))
|
||||||
|
(content))
|
||||||
|
|
||||||
|
==================
|
||||||
|
Include Without A Name
|
||||||
|
:error
|
||||||
|
==================
|
||||||
|
|
||||||
|
{% include %}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
==================
|
||||||
|
Include With Nothing To Bind
|
||||||
|
:error
|
||||||
|
==================
|
||||||
|
|
||||||
|
{% include "t.html" with %}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
==================
|
||||||
|
Include With With Twice
|
||||||
|
:error
|
||||||
|
==================
|
||||||
|
|
||||||
|
{% include "t.html" with a=1 with b=2 %}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
==================
|
||||||
|
Include With Only Twice
|
||||||
|
:error
|
||||||
|
==================
|
||||||
|
|
||||||
|
{% include "t.html" only only %}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
==================
|
||||||
|
Include With An Unknown Option
|
||||||
|
:error
|
||||||
|
==================
|
||||||
|
|
||||||
|
{% include "t.html" bogus %}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
==================
|
||||||
|
Include With A Legacy Binding
|
||||||
|
:error
|
||||||
|
==================
|
||||||
|
|
||||||
|
{% include "t.html" with a as b %}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
==================
|
||||||
|
Include With A Second Name
|
||||||
|
:error
|
||||||
|
==================
|
||||||
|
|
||||||
|
{% include "t.html" "u.html" %}
|
||||||
|
|
||||||
|
---
|
||||||
Reference in new issue
Block a user