Skip to content

Instantly share code, notes, and snippets.

@gregilo
Last active December 17, 2018 17:29
Show Gist options
  • Select an option

  • Save gregilo/303ee76281db87873a18ff280ab11adc to your computer and use it in GitHub Desktop.

Select an option

Save gregilo/303ee76281db87873a18ff280ab11adc to your computer and use it in GitHub Desktop.
Twig Code Snippets for VS Code
{
"Drupal dump": {
"scope": "twig",
"prefix": "dd",
"body": "{{ dd($1) }}"
},
"if": {
"scope": "twig",
"prefix": "if",
"body": [
"{% if ${1:true} %}",
"\t$2",
"{% endif %}"
]
},
"if else": {
"scope": "twig",
"prefix": "ifelse",
"body": [
"{% if ${1:true} %}",
"\t$2",
"{% else %}",
"\t$3",
"{% endif %}"
]
},
"else": {
"scope": "twig",
"prefix": "else",
"body": "{% else %}$1"
},
"endif": {
"scope": "twig",
"prefix": "endif",
"body": "{% endif %}$1"
},
"for": {
"scope": "twig",
"prefix": "for",
"body": [
"{% for ${1:item} in ${2:items} %}",
"\t$3",
"{% endfor %}"
]
},
"Twig dump": {
"scope": "twig",
"prefix": "dump",
"body": "{{ dump($1) }}"
},
"extends": {
"scope": "twig",
"prefix": "extends",
"body": "{% extends '${1:template}' %}$0"
},
"include": {
"scope": "twig",
"prefix": "include",
"body": "{% include '${1:template}' ${2:with ${3:vars}${4: only}} %}"
},
"set": {
"scope": "twig",
"prefix": "set",
"body": "{% set ${1:var} = ${2:value} %}"
},
"block": {
"scope": "twig",
"prefix": "block",
"body": [
"{% block $1 %}",
"\t$2",
"{% endblock %}"
]
},
"print": {
"scope": "twig",
"prefix": "print",
"body": "{{ ${1:value} }}"
},
"trans": {
"scope": "twig",
"prefix": "trans",
"body": "{% trans %}$1{% endtrans %}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment