Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ All snippets use the `pt` prefix (short for "Python Template"). Here's the compl
| `ptj-url` | Static file URL | `{{ url_for('static', filename='file.css') }}` |
| `ptj-mac` | Macro definition | `{% macro name %}...{% endmacro %}` |
| `ptj-set` | Set variable | `{% set var = value %}` |
| `ptj-imp` | Import macro | `{% import 'file.html' as name %}` |
| `ptj-from` | From import macro | `{% from 'file.html' import macro %}` |
| `ptj-raw` | Raw block | `{% raw %}...{% endraw %}` |
| `ptj-fil` | Filter block | `{% filter name %}...{% endfilter %}` |

### 🎨 Django-Specific Snippets
*For Django projects*
Expand Down
40 changes: 40 additions & 0 deletions snippets/jinja-snippets.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,45 @@
"{% set $1 = $2 %}"
],
"description": "Adds Jinja set variable"
},

"Jinja - Import Macro": {
"scope": "html",
"prefix": "ptj-imp",
"body": [
"{% import '${1:filename}.html' as ${2:name} %}$0"
],
"description": "Import macros from template as a namespace"
},

"Jinja - From Import Macro": {
"scope": "html",
"prefix": "ptj-from",
"body": [
"{% from '${1:filename}.html' import ${2:macro} %}$0"
],
"description": "Import specific macro from file"
},

"Jinja - Raw Block": {
"scope": "html",
"prefix": "ptj-raw",
"body": [
"{% raw %}",
"\t$0",
"{% endraw %}"
],
"description": "Escape Jinja template tags (useful for JS frameworks)"
},

"Jinja - Filter Block": {
"scope": "html",
"prefix": "ptj-fil",
"body": [
"{% filter ${1:filter_name} %}",
"\t$0",
"{% endfilter %}"
],
"description": "Filter a block of template code"
}
}