Skip to content

Commit 932b9fa

Browse files
author
RWhiteDev
committed
Added more general template snippets.
1 parent 6a70d72 commit 932b9fa

File tree

4 files changed

+122
-6
lines changed

4 files changed

+122
-6
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ This VS Code snippet extension includes snippets for both the Jinja2 and Django
66

77
To install this extension during development copy it into your local `<user home>/.vscode/extensions` folder and restart VS Code.
88

9+
## Settings
10+
11+
Works best with `editor.tabCompletion` enabled (`on`) in your VS Code `Settings`.
12+
913
## Features
1014

1115
Coming soon...
@@ -20,7 +24,7 @@ Coming soon...
2024

2125
### 0.0.1
2226

23-
Initial development
27+
- Initial development
2428

2529
-----------------------------------------------------------------------------------------------------------
2630

snippets/jinja-snippets.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@
66
"{{ url_for('static', filename='$1') }}$0"
77
],
88
"description": "Link static file with Jinja"
9-
}
9+
},
1010

11+
"Jinja - Macros": {
12+
"scope": "html",
13+
"prefix": "pt-jmac",
14+
"body": [
15+
"{% macro $1 %}",
16+
"\t$0",
17+
"{% endmacro %}"
18+
],
19+
"description": "Adds macro tags"
20+
}
1121
}

snippets/snippets.json

Lines changed: 94 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
"{% block scripts %}",
1313
"{% endblock scripts %}"
1414
],
15-
"description": "Creates the base Jinja / Django template for a new HTML file"
15+
"description": "Creates a simple base Jinja / Django template for a new HTML file"
1616
},
1717

18-
"Jinja / Django Variable": {
18+
"Template Variable": {
1919
"scope": "html",
2020
"prefix": "ptvar",
2121
"body": [
2222
"{{ $1 }}$0"
2323
],
24-
"description": "Opens variable tags"
24+
"description": "Adds variable tags"
2525
},
2626

2727
"Template Code Block": {
@@ -30,7 +30,97 @@
3030
"body": [
3131
"{% $1 %}$0"
3232
],
33-
"description": "Opens code block tags"
33+
"description": "Adds code block tags"
34+
},
35+
36+
"Template Block Tag": {
37+
"scope": "html",
38+
"prefix": "ptblock",
39+
"body": [
40+
"{% block $1 %}",
41+
"\t$0",
42+
"{% endblock $1 %}"
43+
],
44+
"description": "Adds code block tags"
45+
},
46+
47+
"Template For Loop": {
48+
"scope": "html",
49+
"prefix": "ptfor",
50+
"body": [
51+
"{% for $1 in $2 %}",
52+
"\t$0",
53+
"{% endfor %}"
54+
],
55+
"description": "Adds for loop"
56+
},
57+
58+
"Template If Statement": {
59+
"scope": "html",
60+
"prefix": "ptif",
61+
"body": [
62+
"{% if $1 %}",
63+
"\t$0",
64+
"{% endif %}"
65+
],
66+
"description": "Adds if statement"
67+
},
68+
69+
"Template Super": {
70+
"scope": "html",
71+
"prefix": "ptsup",
72+
"body": [
73+
"{{ super() }}"
74+
],
75+
"description": "Adds Super() tag"
76+
},
77+
78+
"Template Extends": {
79+
"scope": "html",
80+
"prefix": "ptext",
81+
"body": [
82+
"{% extends '${1:base.html}' %}$0"
83+
],
84+
"description": "Add extends tag"
85+
},
86+
87+
"Template If/Else Statement": {
88+
"scope": "html",
89+
"prefix": "ptifel",
90+
"body": [
91+
"{% if $1 %}",
92+
"\t$2",
93+
"{% else %}",
94+
"\t$3",
95+
"{% endif %}"
96+
],
97+
"description": "Adds if/else statement"
98+
},
99+
100+
"Template If/Elif/Else Statement": {
101+
"scope": "html",
102+
"prefix": "ptelif",
103+
"body": [
104+
"{% if $1 %}",
105+
"\t$2",
106+
"{% elif $3 %}",
107+
"\t$4",
108+
"{% else %}",
109+
"\t$5",
110+
"{% endif %}"
111+
],
112+
"description": "Adds if/elif/else statement"
113+
},
114+
115+
"Template With Statement": {
116+
"scope": "html",
117+
"prefix": "ptwith",
118+
"body": [
119+
"{% with $1 %}",
120+
"\t$0",
121+
"{% endwith %}"
122+
],
123+
"description": "Adds with statement"
34124
}
35125

36126
}

test.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{% extends 'base.html' %}
2+
3+
4+
{% block content %}
5+
<div class="some-class">
6+
<h1 class=""></h1>
7+
</div>
8+
{% endblock content %}
9+
10+
11+
{% block scripts %}
12+
{% endblock scripts %}

0 commit comments

Comments
 (0)