add clause rule to verbatim, comment, and blocktrans

This commit is contained in:
danhanson committed 2026-09-12 17:41:25 -05:00
1 parent 22362ed393
commit db3caa1672
12 files changed
+25367 -56302

No files matched your search

+7 -4
View File
@@ -112,9 +112,12 @@ the group node does not exist yet.
Do not reach for lookahead to solve that instead: `ts_language_next_state` follows only the shift on `{%`,
which lands in the "a tag starts here" state no matter how the tree is shaped.
`else_clause` is shared by `if_group` and `ifchanged_group`. `comment_group` and `verbatim_group` have no
clause — their bodies are raw scanner text that admits no tags — and neither does `blocktranslate_group`,
whose body is `_translate_body`.
`else_clause` is shared by `if_group` and `ifchanged_group`. `comment_clause` and `verbatim_clause` hold raw
scanner text that admits no tags. `blocktranslate_group` has one clause per spelling, `blocktrans_clause` and
`blocktranslate_clause`, because each must be closed by its own end tag; the counted form nests a
`plural_clause` inside it, since `{% plural %}` is only valid after `count`. Their bodies are
`_translate_body`, not `template`, which is why these four clauses need no `conflicts` entry — the rule
below is about a body that can itself start with `{%`.
**Every clause needs a `conflicts` entry.** The generator offers a left associativity instead; taking it is
what broke `{% for %}` in `06aa870`, where `prec.left` resolved the shift/reduce on `{%` statically and
@@ -248,7 +251,7 @@ captured through its field instead (`(filter name: (identifier))`, `(custom_tag
filter added from a library belongs in it. `queries/locals.scm` relies on the `variable:` field to tell a
binding from a reference — another reason to keep `asVariable` uniform. `{% blocktranslate %}`'s `asvar`
target carries an `asvar:` field instead, because it is written inside the tag but assigned outside it:
the scope on `blocktranslate_group` confines the `with` and `count` bindings, and would swallow `asvar`
the scope on `blocktrans_clause` / `blocktranslate_clause` confines the `with` and `count` bindings, and would swallow `asvar`
too if it were spelled the same way. `queries/exports.scm` names it for a tool to
bind in the scope around the block, which a locals query cannot do: it places a definition in the innermost
scope containing it and offers no way out again.
+35 -29
View File
@@ -204,6 +204,31 @@ function simpleTag($, tag, args = true, kwargs = true) {
return block(tag, ...parts, optional(asVariable($)));
}
/**
* @param {GrammarSymbols<string>} $
* @param {string} tag
* @returns {ChoiceRule}
*/
function blocktrans_clause_rule($, tag) {
return choice(
seq(
block(tag, $._tag_open, repeat($._translate_option)),
optional($._translate_body),
),
seq(
block(
tag,
$._tag_open,
repeat($._translate_option),
$._translate_count,
repeat($._translate_option),
),
optional($._translate_body),
$.plural_clause,
),
);
}
/**
* Django checks a filter's argument count against the registered function
* while it parses the template, so the arity of a builtin is syntax here:
@@ -577,30 +602,13 @@ const django = grammar({
block_clause: ($) =>
seq(block("block", field("name", $.push_block)), optional($.template)),
block_group: ($) => seq($.block_clause, block("endblock", $.pop_block)),
plural_clause: ($) => seq(block("plural"), optional($._translate_body)),
blocktrans_clause: ($) => blocktrans_clause_rule($, "blocktrans"),
blocktranslate_clause: ($) => blocktrans_clause_rule($, "blocktranslate"),
blocktranslate_group: ($) =>
choice(
...["blocktrans", "blocktranslate"].map((name) =>
choice(
seq(
block(name, $._tag_open, repeat($._translate_option)),
optional($._translate_body),
block("end" + name),
),
seq(
block(
name,
$._tag_open,
repeat($._translate_option),
$._translate_count,
repeat($._translate_option),
),
$._translate_body,
block("plural"),
optional($._translate_body),
block("end" + name),
),
),
),
seq($.blocktrans_clause, block("endblocktrans")),
seq($.blocktranslate_clause, block("endblocktranslate")),
),
/**
* The scanner reads the name of the option before the grammar does, so it
@@ -658,12 +666,12 @@ const django = grammar({
optional($.template),
),
cache_group: ($) => seq($.cache_clause, block("endcache")),
comment_group: ($) =>
comment_clause: ($) =>
seq(
block("comment", optional(part($.string))),
optional($.comment_content),
block("endcomment"),
),
comment_group: ($) => seq($.comment_clause, block("endcomment")),
// csp_nonce_attr(context, media=None)
csp_nonce_attr: ($) =>
simpleTag($, "csp_nonce_attr", 1, { media: $.filtered_value }),
@@ -914,12 +922,10 @@ const django = grammar({
),
optional(asVariable($)),
),
verbatim_clause: ($) =>
seq(block("verbatim", $.push_verbatim), optional($.verbatim_content)),
verbatim_group: ($) =>
seq(
block("verbatim", $.push_verbatim),
optional($.verbatim_content),
block("endverbatim", $.pop_verbatim),
),
seq($.verbatim_clause, block("endverbatim", $.pop_verbatim)),
width_ratio: ($) =>
block(
"widthratio",
+4 -1
View File
@@ -21,5 +21,8 @@
; scope span could have separated them; that is why this is a separate file
; rather than a narrower scope in locals.scm.
(blocktranslate_group
(blocktrans_clause
asvar: (identifier) @export.name) @export.from
(blocktranslate_clause
asvar: (identifier) @export.name) @export.from
+1 -1
View File
@@ -10,7 +10,7 @@ variable: (identifier) @variable.parameter
(partialdef_clause
(push_partial) @type)
(verbatim_group
(verbatim_clause
(push_verbatim) @type)
(comment_content) @comment
+5 -4
View File
@@ -24,10 +24,11 @@
(get_media_prefix
tag: ("get_media_prefix") @library.static)
(blocktranslate_group
tag: [
("blocktrans")
("blocktranslate")] @library.i18n)
(blocktrans_clause
tag: ("blocktrans") @library.i18n)
(blocktranslate_clause
tag: ("blocktranslate") @library.i18n)
(translate
tag: [
+2 -1
View File
@@ -23,4 +23,5 @@ variable: (identifier) @local.definition
; outside it, and carries an "asvar" field rather than "variable" so that this
; scope does not swallow it. A tool that wants it must define it in the scope
; around the block, which a locals query has no way to say.
(blocktranslate_group) @local.scope
(blocktrans_clause) @local.scope
(blocktranslate_clause) @local.scope
+416 -498
View File
@@ -1622,82 +1622,409 @@
}
]
},
"plural_clause": {
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "plural"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_translate_body"
},
{
"type": "BLANK"
}
]
}
]
},
"blocktrans_clause": {
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "blocktrans"
}
},
{
"type": "SYMBOL",
"name": "_tag_open"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_translate_option"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_translate_body"
},
{
"type": "BLANK"
}
]
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "blocktrans"
}
},
{
"type": "SYMBOL",
"name": "_tag_open"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_translate_option"
}
},
{
"type": "SYMBOL",
"name": "_translate_count"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_translate_option"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_translate_body"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "plural_clause"
}
]
}
]
},
"blocktranslate_clause": {
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "blocktranslate"
}
},
{
"type": "SYMBOL",
"name": "_tag_open"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_translate_option"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_translate_body"
},
{
"type": "BLANK"
}
]
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "blocktranslate"
}
},
{
"type": "SYMBOL",
"name": "_tag_open"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_translate_option"
}
},
{
"type": "SYMBOL",
"name": "_translate_count"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_translate_option"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_translate_body"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "plural_clause"
}
]
}
]
},
"blocktranslate_group": {
"type": "CHOICE",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "blocktrans"
}
},
{
"type": "SYMBOL",
"name": "_tag_open"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_translate_option"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_translate_body"
},
{
"type": "BLANK"
}
]
"name": "blocktrans_clause"
},
{
"type": "SEQ",
@@ -1749,256 +2076,9 @@
{
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "blocktrans"
}
},
{
"type": "SYMBOL",
"name": "_tag_open"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_translate_option"
}
},
{
"type": "SYMBOL",
"name": "_translate_count"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_translate_option"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
},
{
"type": "SYMBOL",
"name": "_translate_body"
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "plural"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_translate_body"
},
{
"type": "BLANK"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "endblocktrans"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
}
]
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "blocktranslate"
}
},
{
"type": "SYMBOL",
"name": "_tag_open"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_translate_option"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_translate_body"
},
{
"type": "BLANK"
}
]
"name": "blocktranslate_clause"
},
{
"type": "SEQ",
@@ -2046,186 +2126,6 @@
]
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "blocktranslate"
}
},
{
"type": "SYMBOL",
"name": "_tag_open"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_translate_option"
}
},
{
"type": "SYMBOL",
"name": "_translate_count"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_translate_option"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
},
{
"type": "SYMBOL",
"name": "_translate_body"
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "plural"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_translate_body"
},
{
"type": "BLANK"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "endblocktranslate"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
}
]
}
]
}
]
},
@@ -2636,7 +2536,7 @@
}
]
},
"comment_group": {
"comment_clause": {
"type": "SEQ",
"members": [
{
@@ -2716,6 +2616,15 @@
"type": "BLANK"
}
]
}
]
},
"comment_group": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "comment_clause"
},
{
"type": "SEQ",
@@ -8171,7 +8080,7 @@
}
]
},
"verbatim_group": {
"verbatim_clause": {
"type": "SEQ",
"members": [
{
@@ -8234,6 +8143,15 @@
"type": "BLANK"
}
]
}
]
},
"verbatim_group": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "verbatim_clause"
},
{
"type": "SEQ",
+187 -33
View File
@@ -327,7 +327,7 @@
}
},
{
"type": "blocktranslate_group",
"type": "blocktrans_clause",
"named": true,
"fields": {
"asvar": {
@@ -341,28 +341,12 @@
]
},
"tag": {
"multiple": true,
"multiple": false,
"required": true,
"types": [
{
"type": "blocktrans",
"named": false
},
{
"type": "blocktranslate",
"named": false
},
{
"type": "endblocktrans",
"named": false
},
{
"type": "endblocktranslate",
"named": false
},
{
"type": "plural",
"named": false
}
]
},
@@ -389,6 +373,10 @@
"type": "filtered_value",
"named": true
},
{
"type": "plural_clause",
"named": true
},
{
"type": "template_variable",
"named": true
@@ -396,6 +384,98 @@
]
}
},
{
"type": "blocktranslate_clause",
"named": true,
"fields": {
"asvar": {
"multiple": true,
"required": false,
"types": [
{
"type": "identifier",
"named": true
}
]
},
"tag": {
"multiple": false,
"required": true,
"types": [
{
"type": "blocktranslate",
"named": false
}
]
},
"variable": {
"multiple": true,
"required": false,
"types": [
{
"type": "identifier",
"named": true
}
]
}
},
"children": {
"multiple": true,
"required": false,
"types": [
{
"type": "content",
"named": true
},
{
"type": "filtered_value",
"named": true
},
{
"type": "plural_clause",
"named": true
},
{
"type": "template_variable",
"named": true
}
]
}
},
{
"type": "blocktranslate_group",
"named": true,
"fields": {
"tag": {
"multiple": false,
"required": true,
"types": [
{
"type": "endblocktrans",
"named": false
},
{
"type": "endblocktranslate",
"named": false
}
]
}
},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "blocktrans_clause",
"named": true
},
{
"type": "blocktranslate_clause",
"named": true
}
]
}
},
{
"type": "boolean",
"named": true,
@@ -466,20 +546,16 @@
}
},
{
"type": "comment_group",
"type": "comment_clause",
"named": true,
"fields": {
"tag": {
"multiple": true,
"multiple": false,
"required": true,
"types": [
{
"type": "comment",
"named": false
},
{
"type": "endcomment",
"named": false
}
]
}
@@ -499,6 +575,32 @@
]
}
},
{
"type": "comment_group",
"named": true,
"fields": {
"tag": {
"multiple": false,
"required": true,
"types": [
{
"type": "endcomment",
"named": false
}
]
}
},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "comment_clause",
"named": true
}
]
}
},
{
"type": "csp_nonce_attr",
"named": true,
@@ -2009,6 +2111,36 @@
]
}
},
{
"type": "plural_clause",
"named": true,
"fields": {
"tag": {
"multiple": false,
"required": true,
"types": [
{
"type": "plural",
"named": false
}
]
}
},
"children": {
"multiple": true,
"required": false,
"types": [
{
"type": "content",
"named": true
},
{
"type": "template_variable",
"named": true
}
]
}
},
{
"type": "predicate",
"named": true,
@@ -2472,19 +2604,45 @@
}
},
{
"type": "verbatim_group",
"type": "verbatim_clause",
"named": true,
"fields": {
"tag": {
"multiple": false,
"required": true,
"types": [
{
"type": "verbatim",
"named": false
}
]
}
},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "endverbatim",
"named": false
"type": "push_verbatim",
"named": true
},
{
"type": "verbatim",
"type": "verbatim_content",
"named": true
}
]
}
},
{
"type": "verbatim_group",
"named": true,
"fields": {
"tag": {
"multiple": false,
"required": true,
"types": [
{
"type": "endverbatim",
"named": false
}
]
@@ -2499,11 +2657,7 @@
"named": true
},
{
"type": "push_verbatim",
"named": true
},
{
"type": "verbatim_content",
"type": "verbatim_clause",
"named": true
}
]
+24597 -55708
View File
File diff suppressed because it is too large. Load diff
+95 -14
View File
@@ -9,7 +9,8 @@ Blocktrans
(template
(content)
(blocktranslate_group
(content))
(blocktrans_clause
(content)))
(content))
==================
@@ -23,7 +24,8 @@ Blocktranslate
(template
(content)
(blocktranslate_group
(content))
(blocktranslate_clause
(content)))
(content))
==================
@@ -36,7 +38,8 @@ Blocktrans Empty
(template
(content)
(blocktranslate_group)
(blocktranslate_group
(blocktrans_clause))
(content))
==================
@@ -50,12 +53,13 @@ Blocktrans With A Placeholder
(template
(content)
(blocktranslate_group
(blocktrans_clause
(content)
(template_variable
(filtered_value
(value
(variable_attribute
(identifier))))))
(identifier)))))))
(content))
==================
@@ -69,7 +73,8 @@ Blocktrans Trimmed
(template
(content)
(blocktranslate_group
(content))
(blocktrans_clause
(content)))
(content))
==================
@@ -83,12 +88,13 @@ Blocktrans With
(template
(content)
(blocktranslate_group
(blocktrans_clause
variable: (identifier)
(filtered_value
(value
(variable_attribute
(identifier))))
(content))
(content)))
(content))
==================
@@ -102,6 +108,7 @@ Blocktrans With Several Bindings
(template
(content)
(blocktranslate_group
(blocktrans_clause
variable: (identifier)
(filtered_value
(value
@@ -112,7 +119,7 @@ Blocktrans With Several Bindings
(value
(variable_attribute
(identifier))))
(content))
(content)))
(content))
==================
@@ -126,6 +133,7 @@ Blocktrans With A Filtered Binding
(template
(content)
(blocktranslate_group
(blocktrans_clause
variable: (identifier)
(filtered_value
(value
@@ -133,7 +141,7 @@ Blocktrans With A Filtered Binding
(identifier)))
(filter_expression
(filter)))
(content))
(content)))
(content))
==================
@@ -147,11 +155,12 @@ Blocktrans With Context
(template
(content)
(blocktranslate_group
(blocktrans_clause
(filtered_value
(value
(literal
(string))))
(content))
(content)))
(content))
==================
@@ -165,8 +174,9 @@ Blocktrans With Asvar
(template
(content)
(blocktranslate_group
(blocktrans_clause
asvar: (identifier)
(content))
(content)))
(content))
==================
@@ -180,13 +190,57 @@ Blocktrans With Count And Plural
(template
(content)
(blocktranslate_group
(blocktrans_clause
variable: (identifier)
(filtered_value
(value
(variable_attribute
(identifier))))
(content)
(plural_clause
(content))))
(content))
==================
Blocktrans With An Empty Singular
==================
{% blocktrans count n=x %}{% plural %}many{% endblocktrans %}
---
(template
(content)
(blocktranslate_group
(blocktrans_clause
variable: (identifier)
(filtered_value
(value
(variable_attribute
(identifier))))
(plural_clause
(content))))
(content))
==================
Blocktranslate With An Empty Plural
==================
{% blocktranslate count n=x %}one{% plural %}{% endblocktranslate %}
---
(template
(content)
(blocktranslate_group
(blocktranslate_clause
variable: (identifier)
(filtered_value
(value
(variable_attribute
(identifier))))
(content)
(plural_clause)))
(content))
==================
@@ -200,6 +254,7 @@ Blocktrans With Every Option
(template
(content)
(blocktranslate_group
(blocktrans_clause
variable: (identifier)
(filtered_value
(value
@@ -216,7 +271,8 @@ Blocktrans With Every Option
(string))))
asvar: (identifier)
(content)
(content))
(plural_clause
(content))))
(content))
==================
@@ -230,8 +286,9 @@ Blocktrans With Its Options Reordered
(template
(content)
(blocktranslate_group
(blocktrans_clause
asvar: (identifier)
(content))
(content)))
(content))
==================
@@ -244,6 +301,7 @@ Blocktrans Closed By The Other Spelling
---
==================
Blocktranslate Closed By The Other Spelling
:error
@@ -254,6 +312,7 @@ Blocktranslate Closed By The Other Spelling
---
==================
Blocktrans With Count And No Plural
:error
@@ -264,6 +323,7 @@ Blocktrans With Count And No Plural
---
==================
Blocktrans With Plural And No Count
:error
@@ -274,6 +334,7 @@ Blocktrans With Plural And No Count
---
==================
Blocktrans Counting Two Bindings
:error
@@ -284,6 +345,7 @@ Blocktrans Counting Two Bindings
---
==================
Blocktrans With Nothing To Bind
:error
@@ -294,6 +356,7 @@ Blocktrans With Nothing To Bind
---
==================
Blocktrans With An Unknown Option
:error
@@ -304,6 +367,7 @@ Blocktrans With An Unknown Option
---
==================
Blocktrans With Asvar And No Name
:error
@@ -314,6 +378,7 @@ Blocktrans With Asvar And No Name
---
==================
Blocktrans Holding A Tag
:error
@@ -324,6 +389,7 @@ Blocktrans Holding A Tag
---
==================
Blocktrans Holding A Comment
:error
@@ -334,6 +400,7 @@ Blocktrans Holding A Comment
---
==================
Blocktrans Holding Another Blocktrans
:error
@@ -344,6 +411,7 @@ Blocktrans Holding Another Blocktrans
---
==================
Blocktrans With Two Plurals
:error
@@ -354,6 +422,7 @@ Blocktrans With Two Plurals
---
==================
Blocktrans With An Argument On Plural
:error
@@ -363,6 +432,8 @@ Blocktrans With An Argument On Plural
---
==================
Blocktrans With Trimmed Twice
:error
@@ -373,6 +444,7 @@ Blocktrans With Trimmed Twice
---
==================
Blocktrans With With Twice
:error
@@ -383,6 +455,7 @@ Blocktrans With With Twice
---
==================
Blocktrans With Context Twice
:error
@@ -393,6 +466,7 @@ Blocktrans With Context Twice
---
==================
Blocktrans With Asvar Twice
:error
@@ -403,6 +477,7 @@ Blocktrans With Asvar Twice
---
==================
Blocktrans With Count Twice
:error
@@ -413,6 +488,7 @@ Blocktrans With Count Twice
---
==================
Blocktranslate With Trimmed Twice
:error
@@ -423,6 +499,7 @@ Blocktranslate With Trimmed Twice
---
==================
Blocktrans Repeating An Option Of The Tag Before It
==================
@@ -434,9 +511,11 @@ Blocktrans Repeating An Option Of The Tag Before It
(template
(content)
(blocktranslate_group
(content))
(blocktrans_clause
(content)))
(blocktranslate_group
(content))
(blocktrans_clause
(content)))
(content))
==================
@@ -447,3 +526,5 @@ Blocktrans With A Binding Twice
{% blocktrans with a=1 a=2 %}x{% endblocktrans %}
---
+8 -4
View File
@@ -11,7 +11,8 @@ This is ignored
(template
(content)
(comment_group
(comment_content))
(comment_clause
(comment_content)))
(content))
==================
@@ -24,7 +25,8 @@ Comment Empty
(template
(content)
(comment_group)
(comment_group
(comment_clause))
(content))
==================
@@ -40,8 +42,9 @@ This is ignored
(template
(content)
(comment_group
(comment_clause
(string)
(comment_content))
(comment_content)))
(content))
==================
@@ -57,5 +60,6 @@ Contains {% if x %} tag-like text
(template
(content)
(comment_group
(comment_content))
(comment_clause
(comment_content)))
(content))
+10 -5
View File
@@ -9,8 +9,9 @@ Verbatim Basic
(template
(content)
(verbatim_group
(verbatim_clause
(push_verbatim)
(verbatim_content)
(verbatim_content))
(pop_verbatim))
(content))
@@ -25,7 +26,8 @@ Verbatim Empty
(template
(content)
(verbatim_group
(push_verbatim)
(verbatim_clause
(push_verbatim))
(pop_verbatim))
(content))
@@ -43,8 +45,9 @@ Verbatim Ignores Tags
(template
(content)
(verbatim_group
(verbatim_clause
(push_verbatim)
(verbatim_content)
(verbatim_content))
(pop_verbatim))
(content))
@@ -59,8 +62,9 @@ Verbatim With Name
(template
(content)
(verbatim_group
(verbatim_clause
(push_verbatim)
(verbatim_content)
(verbatim_content))
(pop_verbatim))
(content))
@@ -77,7 +81,8 @@ Avoid template rendering via the {% verbatim %}{% endverbatim %} block.
(template
(content)
(verbatim_group
(verbatim_clause
(push_verbatim)
(verbatim_content)
(verbatim_content))
(pop_verbatim))
(content))