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

View File

@ -20,10 +20,28 @@ endsnippet
snippet if "twig if" b snippet if "twig if" b
{% if ${1} %} {% if ${1} %}
${2} ${0:${VISUAL}}
{% endif %} {% endif %}
endsnippet 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 snippet for "twig for" b
{% for ${1} in ${2} %} {% for ${1} in ${2} %}
${3} ${3}

View File

@ -299,7 +299,7 @@ snippet el
${0} ${0}
} }
snippet eif snippet eif
elseif (${1:/* condition */}) { elseif (${1}) {
${0} ${0}
} }
snippet switch 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} %}