mirror of
https://github.com/joshuadavidthomas/django-language-server.git
synced 2025-09-07 02:40: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,
|
||||
nodes: Vec<Node>,
|
||||
},
|
||||
Tag {
|
||||
Closing {
|
||||
tag: Tag,
|
||||
},
|
||||
Inclusion {
|
||||
tag: Tag,
|
||||
template_name: String,
|
||||
},
|
||||
Closing {
|
||||
Single {
|
||||
tag: Tag,
|
||||
},
|
||||
}
|
||||
|
@ -194,21 +194,21 @@ Examples:
|
|||
- `{% else %}`
|
||||
- `{% 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
|
||||
Block::Tag {
|
||||
tag: Tag, // The Tag of the standalone tag
|
||||
Block::Closing {
|
||||
tag: Tag, // The Tag of the closing tag
|
||||
}
|
||||
```
|
||||
|
||||
Examples:
|
||||
|
||||
- `{% csrf_token %}`
|
||||
- `{% load %}`
|
||||
- `{% now "Y-m-d" %}`
|
||||
- `{% endif %}`
|
||||
- `{% endfor %}`
|
||||
- `{% endwith %}`
|
||||
|
||||
##### `Block::Inclusion`
|
||||
|
||||
|
@ -226,21 +226,21 @@ Examples:
|
|||
- `{% include "template.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
|
||||
Block::Closing {
|
||||
tag: Tag, // The Tag of the closing tag
|
||||
Block::Single {
|
||||
tag: Tag, // The Tag of the standalone tag
|
||||
}
|
||||
```
|
||||
|
||||
Examples:
|
||||
|
||||
- `{% endif %}`
|
||||
- `{% endfor %}`
|
||||
- `{% endwith %}`
|
||||
- `{% csrf_token %}`
|
||||
- `{% load %}`
|
||||
- `{% now "Y-m-d" %}`
|
||||
|
||||
## TagSpecs
|
||||
|
||||
|
@ -250,7 +250,7 @@ Tag Specifications (TagSpecs) define how tags are parsed and understood. They al
|
|||
|
||||
```toml
|
||||
[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
|
||||
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" %}
|
||||
```
|
||||
|
||||
- `tag`: Single tags that don't wrap content
|
||||
- `single`: Single tags that don't wrap content
|
||||
|
||||
```django
|
||||
{% csrf_token %}
|
||||
|
@ -325,7 +325,7 @@ args = [{ name = "setting", required = true, allowed_values = ["on", "off"] }]
|
|||
|
||||
```toml
|
||||
[my_module.templatetags.my_tags.my_custom_tag]
|
||||
type = "tag"
|
||||
type = "single"
|
||||
args = [
|
||||
{ name = "arg1", required = true },
|
||||
{ name = "kwarg1", required = false, is_kwarg = true }
|
||||
|
|
|
@ -154,14 +154,14 @@ pub enum Block {
|
|||
tag: Tag,
|
||||
nodes: Vec<Node>,
|
||||
},
|
||||
Tag {
|
||||
Closing {
|
||||
tag: Tag,
|
||||
},
|
||||
Inclusion {
|
||||
tag: Tag,
|
||||
template_name: String,
|
||||
},
|
||||
Closing {
|
||||
Single {
|
||||
tag: Tag,
|
||||
},
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ impl Block {
|
|||
match self {
|
||||
Self::Block { tag, .. }
|
||||
| Self::Branch { tag, .. }
|
||||
| Self::Tag { tag }
|
||||
| Self::Single { tag }
|
||||
| Self::Inclusion { tag, .. }
|
||||
| Self::Closing { tag } => tag,
|
||||
}
|
||||
|
|
|
@ -121,14 +121,14 @@ impl Parser {
|
|||
match spec {
|
||||
Some(spec) => match spec.tag_type {
|
||||
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 => {
|
||||
let template_name = tag.bits.get(1).cloned().unwrap_or_default();
|
||||
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() {
|
||||
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) {
|
||||
closing = Some(Box::new(Block::Closing { tag: inner_tag }));
|
||||
break;
|
||||
} else if self.is_branch_tag(&inner_tag, spec) {
|
||||
nodes.push(self.parse_branch_tag(inner_tag, spec)?);
|
||||
} else {
|
||||
nodes.push(Node::Block(Block::Tag { tag: inner_tag }));
|
||||
nodes.push(Node::Block(Block::Single { tag: inner_tag }));
|
||||
}
|
||||
}
|
||||
Ok(node) => nodes.push(node),
|
||||
|
@ -173,13 +173,13 @@ impl Parser {
|
|||
|
||||
while !self.is_at_end() {
|
||||
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)
|
||||
{
|
||||
self.backtrack(1)?;
|
||||
break;
|
||||
} 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),
|
||||
|
|
|
@ -4,7 +4,7 @@ expression: ast
|
|||
---
|
||||
nodes:
|
||||
- Block:
|
||||
Tag:
|
||||
Single:
|
||||
tag:
|
||||
name: url
|
||||
bits:
|
||||
|
|
|
@ -138,7 +138,7 @@ impl TagSpec {
|
|||
#[serde(rename_all = "lowercase")]
|
||||
pub enum TagType {
|
||||
Block,
|
||||
Tag,
|
||||
Single,
|
||||
Inclusion,
|
||||
}
|
||||
|
||||
|
|
|
@ -13,14 +13,14 @@ closing = "endcomment"
|
|||
|
||||
|
||||
[django.template.defaulttags.cycle]
|
||||
type = "tag"
|
||||
type = "single"
|
||||
args = [
|
||||
{ name = "cyclevars", required = true },
|
||||
{ name = "variable_name", required = false, is_kwarg = true },
|
||||
]
|
||||
|
||||
[django.template.defaulttags.debug]
|
||||
type = "tag"
|
||||
type = "single"
|
||||
|
||||
[django.template.defaulttags.extends]
|
||||
type = "inclusion"
|
||||
|
@ -42,7 +42,7 @@ closing = "endfilter"
|
|||
args = [{ name = "filter_expr", required = true }]
|
||||
|
||||
[django.template.defaulttags.firstof]
|
||||
type = "tag"
|
||||
type = "single"
|
||||
args = [{ name = "variables", required = true }]
|
||||
|
||||
[django.template.defaulttags.if]
|
||||
|
@ -60,11 +60,11 @@ args = [
|
|||
]
|
||||
|
||||
[django.template.defaulttags.load]
|
||||
type = "tag"
|
||||
type = "single"
|
||||
args = [{ name = "library", required = true }]
|
||||
|
||||
[django.template.defaulttags.now]
|
||||
type = "tag"
|
||||
type = "single"
|
||||
args = [{ name = "format_string", required = true }]
|
||||
|
||||
[django.template.defaulttags.spaceless]
|
||||
|
@ -72,7 +72,7 @@ type = "block"
|
|||
closing = "endspaceless"
|
||||
|
||||
[django.template.defaulttags.templatetag]
|
||||
type = "tag"
|
||||
type = "single"
|
||||
|
||||
[[django.template.defaulttags.templatetag.args]]
|
||||
name = "tagtype"
|
||||
|
@ -89,7 +89,7 @@ allowed_values = [
|
|||
]
|
||||
|
||||
[django.template.defaulttags.url]
|
||||
type = "tag"
|
||||
type = "single"
|
||||
args = [
|
||||
{ name = "view_name", required = true },
|
||||
{ name = "asvar", required = false, is_kwarg = true },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue