Skip to content

Instantly share code, notes, and snippets.

@HymanZHAN
Last active April 29, 2022 01:39
Show Gist options
  • Save HymanZHAN/142e387a13e9866a453af61d9fb7edef to your computer and use it in GitHub Desktop.
Save HymanZHAN/142e387a13e9866a453af61d9fb7edef to your computer and use it in GitHub Desktop.
Some Handy HTML Snippets for Jinja2 Templates (updating)
{
"Jinja For": {
"prefix": "jj-for",
"body": ["{% for ${2:element} in ${1:array} %}", "\t$0", "{% endfor %}"],
"description": "For loop in Jinja2"
},
"Jinja If": {
"prefix": "jj-if",
"body": ["{% if ${1:expression} %}", "\t$0", "{% endif %}"],
"description": "If statement in Jinja2"
},
"Jinja Else": {
"prefix": "jj-else",
"body": "{% else %}",
"description": "Else statement in Jinja2"
},
"Jinja Extend": {
"prefix": "jj-extends",
"body": "{% extends \"${1:base.html}\" %}",
"description": "Template inheritance in Jinja2"
},
"Jinja Block": {
"prefix": "jj-block",
"body": ["{% block ${1:block_name} %}", "\t$0", "{% endblock %}"],
"description": "Declare a block in Jinja2"
},
"Jinja With": {
"prefix": "jj-with",
"body": [
"{% with ${1:variable} = ${2:expression} %}",
"\t$0",
"{% endwith %}"
]
}
}
@HymanZHAN
Copy link
Author

HymanZHAN commented Oct 1, 2018

This is to provide a more pleasant developer experience when coding Jinja2 templates for Flask applications. For VS Code users, ctrl + ship + p / cmd + shift + p and search for Configure User Snippets. Select HTML for the file type and copy the above configuration into the html.json file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment