aboutsummaryrefslogtreecommitdiff
path: root/vim/bundle/vim-snippets/UltiSnips/jinja2.snippets
blob: ded01dcf0bb1347a6ed8a28d0b1d0c051825c4c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
priority -50

# http://jinja.pocoo.org/

# jinja2 is a full featured template engine for Python. It has full
# unicode support, an optional integrated sandboxed execution
# environment, widely used and BSD licensed.

# possible extends:
#extends html


snippet block "block" b
{% block ${1:name} %}
		$2
{% endblock $1 %}
endsnippet


snippet {{ "variable" b
{{ $1 }}
endsnippet


snippet {# "comment" b
{# $1 #}
endsnippet


snippet # "comment" b
{# $1 #}
endsnippet


snippet raw "escaped block" b
{% raw %}
		$1
{% endraw %}
endsnippet


snippet extends "extends" b
{% extends "${1:template}" %}
endsnippet


snippet include "include" b
{% include "${1:template}" %}
endsnippet


snippet import "import" b
{% import "${1:template}" %}
endsnippet


snippet from "from/import/as" b
{% from "${1:template}" import ${2:name}${3: as ${4:$2}} %}
endsnippet


snippet filter "filter" b
{% filter ${1:filter} %}
	$2
{% endfilter %}
endsnippet


# Being able to quickly remove the whole 'else' block seems faster to me than
# choosing between 'for' and 'for/else' snippets from the menu.
# snippet for "for" b
# {% for ${1:item} in ${2:sequence} %}
#     $3${4:
# {% else %}
#     $5}
# {% endfor %}
# endsnippet


snippet for "for" b
{% for ${1:item} in ${2:sequence} %}
	$3
{% endfor %}
endsnippet


snippet for "for/else" b
{% for ${1:item} in ${2:sequence} %}
	$3
{% else %}
	$4
{% endfor %}
endsnippet


snippet if "if" b
{% if ${1:expr} %}
	$2
{% endif %}
endsnippet


snippet if "if/else" b
{% if ${1:expr} %}
	$2
{% else %}
	$3
{% endif %}
endsnippet


snippet if "if/elif/else" b
{% if ${1:expr} %}
	$2
{% elif %}
	$3
{% else %}
	$4
{% endif %}
endsnippet


snippet macro "macro" b
{% macro ${1:name}(${2:args}) %}
	$3
{% endmacro %}
endsnippet


snippet call "call" b
{% call ${1:name}(${2:args}) %}
	$3
{% endcall %}
endsnippet


snippet set "set" b
{% set ${1:name} = ${2:'value'} %}
endsnippet


snippet trans "translation" b
{% trans %}
	$1
{% endtrans %}
endsnippet


snippet with "with" b
{% with %}
	$1
{% endwith %}
endsnippet

snippet autoescape "autoescape" b
{% autoescape ${1:true} %}
	$2
{% endautoescape %}
endsnippet

# Filters
# @todo: expand only when snippet is preceeded by a |

snippet batch "batch items" w
batch(linecount=$1, fill_with=${2:None})
endsnippet


snippet dictsort "sort and yield (key, value) pairs" w
dictsort(case_sensitive=${1:False}, by=${2:'key'})
endsnippet


snippet round "round number" w
round(precision=${1:0}, method=${2:'common|ceil|floor'})
endsnippet


snippet urlize "convert plain-text url to <a/>" w
urlize(trim_url_limit=${1:None}, nofollow=${2:False})
endsnippet


snippet wordwrap "wordwrap" w
wordwrap(width=${1:79}, break_long_words=${2:True})
endsnippet


snippet truncate "truncate" w
truncate(lenght=${1:79}, killwords=${2:False}, end=${3:'...''})
endsnippet


snippet sum "sum of sequence of numbers + start" w
sum(attribute=${1:None}, start=${2:0})
endsnippet


snippet sort "sort an iterable" w
sort(reverse=${1:False}, case_sensitive=${2:False}, attribute=${3:None})
endsnippet


snippet indent "indent" w
indent(width=${1:4}, indentfirst=${2:False})
endsnippet


# vim:ft=snippets: