Merge pull request #728 from codeinabox/php-twig-conditional

PHP and Twig conditional snippets to be consistent with naming convention
This commit is contained in:
Louis Pilfold 2016-05-05 15:11:11 +01:00
commit c3f1a708be
4 changed files with 76 additions and 9 deletions

View File

@ -11,6 +11,12 @@ snippet def "def"
define('${1:VARIABLE_NAME}', ${2:'definition'});${3}
endsnippet
snippet wh "while"
while (${1}) {
${0:${VISUAL}}
}
endsnippet
snippet do "do"
do {
${2:// code... }
@ -39,9 +45,9 @@ interface ${1:someClass}
} // END interface $1"
endsnippet
snippet else "else"
snippet el "else"
else {
${1:// code...}
${0:${VISUAL}}
}
endsnippet
@ -62,14 +68,14 @@ $_GET['${1}']${2}
endsnippet
snippet if "if"
if (${1:/* condition */}) {
${2:// code...}
if (${1}) {
${0:${VISUAL}}
}
endsnippet
snippet elif "elseif"
elseif (${1:/* condition */}) {
${2:// code...}
snippet eif "elseif"
elseif (${1}) {
${0:${VISUAL}}
}
endsnippet

View File

@ -20,10 +20,28 @@ endsnippet
snippet if "twig if" b
{% if ${1} %}
${2}
${0:${VISUAL}}
{% endif %}
endsnippet
snippet ife "twig if ... else" b
{% if ${1} %}
${2}
{% else %}
${0}
{% endif %}
endsnippet
snippet el "twig else"
{% else %}
${0:${VISUAL}}
endsnippet
snippet eif "twig elseif"
{% elseif ${1} %}
${0:${VISUAL}}
endsnippet
snippet for "twig for" b
{% for ${1} in ${2} %}
${3}

View File

@ -299,7 +299,7 @@ snippet el
${0}
}
snippet eif
elseif (${1:/* condition */}) {
elseif (${1}) {
${0}
}
snippet switch

43
snippets/twig.snippets Normal file
View File

@ -0,0 +1,43 @@
# twig block
snippet bl
{% block ${1} %}
${2}
{% endblock $1 %}
# twig javascripts
snippet js
{% javascripts '${1}' %}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
# twig stylesheets
snippet css
{% stylesheets '${1}' %}
<link rel="stylesheet" href="{{ asset_url }}">
{% endstylesheets %}
# twig if
snippet if
{% if ${1} %}
${2}
{% endif %}
# twig if ... else
snippet ife
{% if ${1} %}
${2}
{% else %}
${0}
{% endif %}
# twig else
snippet el
{% else %}
${0}
# twig elseif
snippet eif
{% elseif ${1} %}
${0}
# twig for
snippet for
{% for ${1} in ${2} %}
${3}
{% endfor %}
# twig extends
snippet ext
{% extends ${1} %}