mirror of
https://github.com/joshuadavidthomas/django-language-server.git
synced 2025-09-11 04:46:38 +00:00
rename tag enum member to single
This commit is contained in:
parent
dca173cfb5
commit
00f3fb3c47
6 changed files with 37 additions and 37 deletions
|
@ -119,14 +119,14 @@ pub enum Block {
|
||||||
tag: Tag,
|
tag: Tag,
|
||||||
nodes: Vec<Node>,
|
nodes: Vec<Node>,
|
||||||
},
|
},
|
||||||
Tag {
|
Closing {
|
||||||
tag: Tag,
|
tag: Tag,
|
||||||
},
|
},
|
||||||
Inclusion {
|
Inclusion {
|
||||||
tag: Tag,
|
tag: Tag,
|
||||||
template_name: String,
|
template_name: String,
|
||||||
},
|
},
|
||||||
Closing {
|
Single {
|
||||||
tag: Tag,
|
tag: Tag,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -194,21 +194,21 @@ Examples:
|
||||||
- `{% else %}`
|
- `{% else %}`
|
||||||
- `{% empty %}`
|
- `{% empty %}`
|
||||||
|
|
||||||
##### `Block::Tag`
|
##### `Block::Closing`
|
||||||
|
|
||||||
Represents standalone tags that do not contain child nodes or require a closing tag.
|
Represents closing tags corresponding to opening block tags.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
Block::Tag {
|
Block::Closing {
|
||||||
tag: Tag, // The Tag of the standalone tag
|
tag: Tag, // The Tag of the closing tag
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
- `{% csrf_token %}`
|
- `{% endif %}`
|
||||||
- `{% load %}`
|
- `{% endfor %}`
|
||||||
- `{% now "Y-m-d" %}`
|
- `{% endwith %}`
|
||||||
|
|
||||||
##### `Block::Inclusion`
|
##### `Block::Inclusion`
|
||||||
|
|
||||||
|
@ -226,21 +226,21 @@ Examples:
|
||||||
- `{% include "template.html" %}`
|
- `{% include "template.html" %}`
|
||||||
- `{% extends "base.html" %}`
|
- `{% extends "base.html" %}`
|
||||||
|
|
||||||
##### `Block::Closing`
|
##### `Block::Single`
|
||||||
|
|
||||||
Represents closing tags corresponding to opening block tags.
|
Represents standalone tags that do not contain child nodes or require a closing tag.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
Block::Closing {
|
Block::Single {
|
||||||
tag: Tag, // The Tag of the closing tag
|
tag: Tag, // The Tag of the standalone tag
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
- `{% endif %}`
|
- `{% csrf_token %}`
|
||||||
- `{% endfor %}`
|
- `{% load %}`
|
||||||
- `{% endwith %}`
|
- `{% now "Y-m-d" %}`
|
||||||
|
|
||||||
## TagSpecs
|
## TagSpecs
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ Tag Specifications (TagSpecs) define how tags are parsed and understood. They al
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[package.module.path.tag_name] # Path where tag is registered, e.g., django.template.defaulttags
|
[package.module.path.tag_name] # Path where tag is registered, e.g., django.template.defaulttags
|
||||||
type = "block" | "inclusion" | "tag"
|
type = "block" | "inclusion" | "single"
|
||||||
closing = "closing_tag_name" # For block tags that require a closing tag
|
closing = "closing_tag_name" # For block tags that require a closing tag
|
||||||
branches = ["branch_tag_name", ...] # For block tags that support branches
|
branches = ["branch_tag_name", ...] # For block tags that support branches
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ The `name` field in args should match the internal name used in Django's node im
|
||||||
{% include "partial.html" %}
|
{% include "partial.html" %}
|
||||||
```
|
```
|
||||||
|
|
||||||
- `tag`: Single tags that don't wrap content
|
- `single`: Single tags that don't wrap content
|
||||||
|
|
||||||
```django
|
```django
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
@ -325,7 +325,7 @@ args = [{ name = "setting", required = true, allowed_values = ["on", "off"] }]
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[my_module.templatetags.my_tags.my_custom_tag]
|
[my_module.templatetags.my_tags.my_custom_tag]
|
||||||
type = "tag"
|
type = "single"
|
||||||
args = [
|
args = [
|
||||||
{ name = "arg1", required = true },
|
{ name = "arg1", required = true },
|
||||||
{ name = "kwarg1", required = false, is_kwarg = true }
|
{ name = "kwarg1", required = false, is_kwarg = true }
|
||||||
|
|
|
@ -154,14 +154,14 @@ pub enum Block {
|
||||||
tag: Tag,
|
tag: Tag,
|
||||||
nodes: Vec<Node>,
|
nodes: Vec<Node>,
|
||||||
},
|
},
|
||||||
Tag {
|
Closing {
|
||||||
tag: Tag,
|
tag: Tag,
|
||||||
},
|
},
|
||||||
Inclusion {
|
Inclusion {
|
||||||
tag: Tag,
|
tag: Tag,
|
||||||
template_name: String,
|
template_name: String,
|
||||||
},
|
},
|
||||||
Closing {
|
Single {
|
||||||
tag: Tag,
|
tag: Tag,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ impl Block {
|
||||||
match self {
|
match self {
|
||||||
Self::Block { tag, .. }
|
Self::Block { tag, .. }
|
||||||
| Self::Branch { tag, .. }
|
| Self::Branch { tag, .. }
|
||||||
| Self::Tag { tag }
|
| Self::Single { tag }
|
||||||
| Self::Inclusion { tag, .. }
|
| Self::Inclusion { tag, .. }
|
||||||
| Self::Closing { tag } => tag,
|
| Self::Closing { tag } => tag,
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,14 +121,14 @@ impl Parser {
|
||||||
match spec {
|
match spec {
|
||||||
Some(spec) => match spec.tag_type {
|
Some(spec) => match spec.tag_type {
|
||||||
TagType::Block => self.parse_block_tag(tag, spec),
|
TagType::Block => self.parse_block_tag(tag, spec),
|
||||||
TagType::Tag => Ok(Node::Block(Block::Tag { tag })),
|
TagType::Single => Ok(Node::Block(Block::Single { tag })),
|
||||||
TagType::Inclusion => {
|
TagType::Inclusion => {
|
||||||
let template_name = tag.bits.get(1).cloned().unwrap_or_default();
|
let template_name = tag.bits.get(1).cloned().unwrap_or_default();
|
||||||
Ok(Node::Block(Block::Inclusion { tag, template_name }))
|
Ok(Node::Block(Block::Inclusion { tag, template_name }))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
None => Ok(Node::Block(Block::Tag { tag })),
|
None => Ok(Node::Block(Block::Single { tag })),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,14 +138,14 @@ impl Parser {
|
||||||
|
|
||||||
while !self.is_at_end() {
|
while !self.is_at_end() {
|
||||||
match self.next_node() {
|
match self.next_node() {
|
||||||
Ok(Node::Block(Block::Tag { tag: inner_tag })) => {
|
Ok(Node::Block(Block::Single { tag: inner_tag })) => {
|
||||||
if self.is_closing_tag(&inner_tag, spec) {
|
if self.is_closing_tag(&inner_tag, spec) {
|
||||||
closing = Some(Box::new(Block::Closing { tag: inner_tag }));
|
closing = Some(Box::new(Block::Closing { tag: inner_tag }));
|
||||||
break;
|
break;
|
||||||
} else if self.is_branch_tag(&inner_tag, spec) {
|
} else if self.is_branch_tag(&inner_tag, spec) {
|
||||||
nodes.push(self.parse_branch_tag(inner_tag, spec)?);
|
nodes.push(self.parse_branch_tag(inner_tag, spec)?);
|
||||||
} else {
|
} else {
|
||||||
nodes.push(Node::Block(Block::Tag { tag: inner_tag }));
|
nodes.push(Node::Block(Block::Single { tag: inner_tag }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(node) => nodes.push(node),
|
Ok(node) => nodes.push(node),
|
||||||
|
@ -173,13 +173,13 @@ impl Parser {
|
||||||
|
|
||||||
while !self.is_at_end() {
|
while !self.is_at_end() {
|
||||||
match self.next_node() {
|
match self.next_node() {
|
||||||
Ok(Node::Block(Block::Tag { tag: inner_tag })) => {
|
Ok(Node::Block(Block::Single { tag: inner_tag })) => {
|
||||||
if self.is_closing_tag(&inner_tag, spec) || self.is_branch_tag(&inner_tag, spec)
|
if self.is_closing_tag(&inner_tag, spec) || self.is_branch_tag(&inner_tag, spec)
|
||||||
{
|
{
|
||||||
self.backtrack(1)?;
|
self.backtrack(1)?;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
branch_nodes.push(Node::Block(Block::Tag { tag: inner_tag }));
|
branch_nodes.push(Node::Block(Block::Single { tag: inner_tag }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(node) => branch_nodes.push(node),
|
Ok(node) => branch_nodes.push(node),
|
||||||
|
|
|
@ -4,7 +4,7 @@ expression: ast
|
||||||
---
|
---
|
||||||
nodes:
|
nodes:
|
||||||
- Block:
|
- Block:
|
||||||
Tag:
|
Single:
|
||||||
tag:
|
tag:
|
||||||
name: url
|
name: url
|
||||||
bits:
|
bits:
|
||||||
|
|
|
@ -138,7 +138,7 @@ impl TagSpec {
|
||||||
#[serde(rename_all = "lowercase")]
|
#[serde(rename_all = "lowercase")]
|
||||||
pub enum TagType {
|
pub enum TagType {
|
||||||
Block,
|
Block,
|
||||||
Tag,
|
Single,
|
||||||
Inclusion,
|
Inclusion,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,14 +13,14 @@ closing = "endcomment"
|
||||||
|
|
||||||
|
|
||||||
[django.template.defaulttags.cycle]
|
[django.template.defaulttags.cycle]
|
||||||
type = "tag"
|
type = "single"
|
||||||
args = [
|
args = [
|
||||||
{ name = "cyclevars", required = true },
|
{ name = "cyclevars", required = true },
|
||||||
{ name = "variable_name", required = false, is_kwarg = true },
|
{ name = "variable_name", required = false, is_kwarg = true },
|
||||||
]
|
]
|
||||||
|
|
||||||
[django.template.defaulttags.debug]
|
[django.template.defaulttags.debug]
|
||||||
type = "tag"
|
type = "single"
|
||||||
|
|
||||||
[django.template.defaulttags.extends]
|
[django.template.defaulttags.extends]
|
||||||
type = "inclusion"
|
type = "inclusion"
|
||||||
|
@ -42,7 +42,7 @@ closing = "endfilter"
|
||||||
args = [{ name = "filter_expr", required = true }]
|
args = [{ name = "filter_expr", required = true }]
|
||||||
|
|
||||||
[django.template.defaulttags.firstof]
|
[django.template.defaulttags.firstof]
|
||||||
type = "tag"
|
type = "single"
|
||||||
args = [{ name = "variables", required = true }]
|
args = [{ name = "variables", required = true }]
|
||||||
|
|
||||||
[django.template.defaulttags.if]
|
[django.template.defaulttags.if]
|
||||||
|
@ -60,11 +60,11 @@ args = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[django.template.defaulttags.load]
|
[django.template.defaulttags.load]
|
||||||
type = "tag"
|
type = "single"
|
||||||
args = [{ name = "library", required = true }]
|
args = [{ name = "library", required = true }]
|
||||||
|
|
||||||
[django.template.defaulttags.now]
|
[django.template.defaulttags.now]
|
||||||
type = "tag"
|
type = "single"
|
||||||
args = [{ name = "format_string", required = true }]
|
args = [{ name = "format_string", required = true }]
|
||||||
|
|
||||||
[django.template.defaulttags.spaceless]
|
[django.template.defaulttags.spaceless]
|
||||||
|
@ -72,7 +72,7 @@ type = "block"
|
||||||
closing = "endspaceless"
|
closing = "endspaceless"
|
||||||
|
|
||||||
[django.template.defaulttags.templatetag]
|
[django.template.defaulttags.templatetag]
|
||||||
type = "tag"
|
type = "single"
|
||||||
|
|
||||||
[[django.template.defaulttags.templatetag.args]]
|
[[django.template.defaulttags.templatetag.args]]
|
||||||
name = "tagtype"
|
name = "tagtype"
|
||||||
|
@ -89,7 +89,7 @@ allowed_values = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[django.template.defaulttags.url]
|
[django.template.defaulttags.url]
|
||||||
type = "tag"
|
type = "single"
|
||||||
args = [
|
args = [
|
||||||
{ name = "view_name", required = true },
|
{ name = "view_name", required = true },
|
||||||
{ name = "asvar", required = false, is_kwarg = true },
|
{ name = "asvar", required = false, is_kwarg = true },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue