1
0
Fork 0
mirror of synced 2024-11-04 16:38:59 -05:00
ultimate-vim/sources_non_forked/vim-snippets/UltiSnips/jinja2.snippets

209 lines
3.1 KiB
Text

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: