Skip to content

Commit 00f3fb3

Browse files
rename tag enum member to single
1 parent dca173c commit 00f3fb3

File tree

6 files changed

+37
-37
lines changed

6 files changed

+37
-37
lines changed

crates/djls-template-ast/SPEC.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,14 @@ pub enum Block {
119119
tag: Tag,
120120
nodes: Vec<Node>,
121121
},
122-
Tag {
122+
Closing {
123123
tag: Tag,
124124
},
125125
Inclusion {
126126
tag: Tag,
127127
template_name: String,
128128
},
129-
Closing {
129+
Single {
130130
tag: Tag,
131131
},
132132
}
@@ -194,21 +194,21 @@ Examples:
194194
- `{% else %}`
195195
- `{% empty %}`
196196

197-
##### `Block::Tag`
197+
##### `Block::Closing`
198198

199-
Represents standalone tags that do not contain child nodes or require a closing tag.
199+
Represents closing tags corresponding to opening block tags.
200200

201201
```rust
202-
Block::Tag {
203-
tag: Tag, // The Tag of the standalone tag
202+
Block::Closing {
203+
tag: Tag, // The Tag of the closing tag
204204
}
205205
```
206206

207207
Examples:
208208

209-
- `{% csrf_token %}`
210-
- `{% load %}`
211-
- `{% now "Y-m-d" %}`
209+
- `{% endif %}`
210+
- `{% endfor %}`
211+
- `{% endwith %}`
212212

213213
##### `Block::Inclusion`
214214

@@ -226,21 +226,21 @@ Examples:
226226
- `{% include "template.html" %}`
227227
- `{% extends "base.html" %}`
228228

229-
##### `Block::Closing`
229+
##### `Block::Single`
230230

231-
Represents closing tags corresponding to opening block tags.
231+
Represents standalone tags that do not contain child nodes or require a closing tag.
232232

233233
```rust
234-
Block::Closing {
235-
tag: Tag, // The Tag of the closing tag
234+
Block::Single {
235+
tag: Tag, // The Tag of the standalone tag
236236
}
237237
```
238238

239239
Examples:
240240

241-
- `{% endif %}`
242-
- `{% endfor %}`
243-
- `{% endwith %}`
241+
- `{% csrf_token %}`
242+
- `{% load %}`
243+
- `{% now "Y-m-d" %}`
244244

245245
## TagSpecs
246246

@@ -250,7 +250,7 @@ Tag Specifications (TagSpecs) define how tags are parsed and understood. They al
250250

251251
```toml
252252
[package.module.path.tag_name] # Path where tag is registered, e.g., django.template.defaulttags
253-
type = "block" | "inclusion" | "tag"
253+
type = "block" | "inclusion" | "single"
254254
closing = "closing_tag_name" # For block tags that require a closing tag
255255
branches = ["branch_tag_name", ...] # For block tags that support branches
256256

@@ -281,7 +281,7 @@ The `name` field in args should match the internal name used in Django's node im
281281
{% include "partial.html" %}
282282
```
283283

284-
- `tag`: Single tags that don't wrap content
284+
- `single`: Single tags that don't wrap content
285285

286286
```django
287287
{% csrf_token %}
@@ -325,7 +325,7 @@ args = [{ name = "setting", required = true, allowed_values = ["on", "off"] }]
325325

326326
```toml
327327
[my_module.templatetags.my_tags.my_custom_tag]
328-
type = "tag"
328+
type = "single"
329329
args = [
330330
{ name = "arg1", required = true },
331331
{ name = "kwarg1", required = false, is_kwarg = true }

crates/djls-template-ast/src/ast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,14 @@ pub enum Block {
154154
tag: Tag,
155155
nodes: Vec<Node>,
156156
},
157-
Tag {
157+
Closing {
158158
tag: Tag,
159159
},
160160
Inclusion {
161161
tag: Tag,
162162
template_name: String,
163163
},
164-
Closing {
164+
Single {
165165
tag: Tag,
166166
},
167167
}
@@ -171,7 +171,7 @@ impl Block {
171171
match self {
172172
Self::Block { tag, .. }
173173
| Self::Branch { tag, .. }
174-
| Self::Tag { tag }
174+
| Self::Single { tag }
175175
| Self::Inclusion { tag, .. }
176176
| Self::Closing { tag } => tag,
177177
}

crates/djls-template-ast/src/parser.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,14 @@ impl Parser {
121121
match spec {
122122
Some(spec) => match spec.tag_type {
123123
TagType::Block => self.parse_block_tag(tag, spec),
124-
TagType::Tag => Ok(Node::Block(Block::Tag { tag })),
124+
TagType::Single => Ok(Node::Block(Block::Single { tag })),
125125
TagType::Inclusion => {
126126
let template_name = tag.bits.get(1).cloned().unwrap_or_default();
127127
Ok(Node::Block(Block::Inclusion { tag, template_name }))
128128
}
129129
},
130130

131-
None => Ok(Node::Block(Block::Tag { tag })),
131+
None => Ok(Node::Block(Block::Single { tag })),
132132
}
133133
}
134134

@@ -138,14 +138,14 @@ impl Parser {
138138

139139
while !self.is_at_end() {
140140
match self.next_node() {
141-
Ok(Node::Block(Block::Tag { tag: inner_tag })) => {
141+
Ok(Node::Block(Block::Single { tag: inner_tag })) => {
142142
if self.is_closing_tag(&inner_tag, spec) {
143143
closing = Some(Box::new(Block::Closing { tag: inner_tag }));
144144
break;
145145
} else if self.is_branch_tag(&inner_tag, spec) {
146146
nodes.push(self.parse_branch_tag(inner_tag, spec)?);
147147
} else {
148-
nodes.push(Node::Block(Block::Tag { tag: inner_tag }));
148+
nodes.push(Node::Block(Block::Single { tag: inner_tag }));
149149
}
150150
}
151151
Ok(node) => nodes.push(node),
@@ -173,13 +173,13 @@ impl Parser {
173173

174174
while !self.is_at_end() {
175175
match self.next_node() {
176-
Ok(Node::Block(Block::Tag { tag: inner_tag })) => {
176+
Ok(Node::Block(Block::Single { tag: inner_tag })) => {
177177
if self.is_closing_tag(&inner_tag, spec) || self.is_branch_tag(&inner_tag, spec)
178178
{
179179
self.backtrack(1)?;
180180
break;
181181
} else {
182-
branch_nodes.push(Node::Block(Block::Tag { tag: inner_tag }));
182+
branch_nodes.push(Node::Block(Block::Single { tag: inner_tag }));
183183
}
184184
}
185185
Ok(node) => branch_nodes.push(node),

crates/djls-template-ast/src/snapshots/djls_template_ast__parser__tests__django__parse_django_tag_assignment.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ expression: ast
44
---
55
nodes:
66
- Block:
7-
Tag:
7+
Single:
88
tag:
99
name: url
1010
bits:

crates/djls-template-ast/src/tagspecs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl TagSpec {
138138
#[serde(rename_all = "lowercase")]
139139
pub enum TagType {
140140
Block,
141-
Tag,
141+
Single,
142142
Inclusion,
143143
}
144144

crates/djls-template-ast/tagspecs/django.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ closing = "endcomment"
1313

1414

1515
[django.template.defaulttags.cycle]
16-
type = "tag"
16+
type = "single"
1717
args = [
1818
{ name = "cyclevars", required = true },
1919
{ name = "variable_name", required = false, is_kwarg = true },
2020
]
2121

2222
[django.template.defaulttags.debug]
23-
type = "tag"
23+
type = "single"
2424

2525
[django.template.defaulttags.extends]
2626
type = "inclusion"
@@ -42,7 +42,7 @@ closing = "endfilter"
4242
args = [{ name = "filter_expr", required = true }]
4343

4444
[django.template.defaulttags.firstof]
45-
type = "tag"
45+
type = "single"
4646
args = [{ name = "variables", required = true }]
4747

4848
[django.template.defaulttags.if]
@@ -60,19 +60,19 @@ args = [
6060
]
6161

6262
[django.template.defaulttags.load]
63-
type = "tag"
63+
type = "single"
6464
args = [{ name = "library", required = true }]
6565

6666
[django.template.defaulttags.now]
67-
type = "tag"
67+
type = "single"
6868
args = [{ name = "format_string", required = true }]
6969

7070
[django.template.defaulttags.spaceless]
7171
type = "block"
7272
closing = "endspaceless"
7373

7474
[django.template.defaulttags.templatetag]
75-
type = "tag"
75+
type = "single"
7676

7777
[[django.template.defaulttags.templatetag.args]]
7878
name = "tagtype"
@@ -89,7 +89,7 @@ allowed_values = [
8989
]
9090

9191
[django.template.defaulttags.url]
92-
type = "tag"
92+
type = "single"
9393
args = [
9494
{ name = "view_name", required = true },
9595
{ name = "asvar", required = false, is_kwarg = true },

0 commit comments

Comments
 (0)