Skip to content
Open
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
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# Jinja for Visual Studio Code
# Django Templates for Visual Studio Code

[![Join the chat at https://gitter.im/wholroyd/vscode-jinja](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/wholroyd/vscode-jinja?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
This extension adds language colorization support and user snippets for the Django template language to VS Code.

This extension adds language colorization support for the Jinja template language to VS Code.
This is based on the [Jinja extension](https://marketplace.visualstudio.com/items?itemName=wholroyd.jinja) by the awesome [wholroyd](https://github.com/wholroyd/vscode-jinja/).

![IDE](https://raw.githubusercontent.com/wholroyd/vscode-jinja/master/example.png)
![IDE](https://raw.githubusercontent.com/iambibhas/vscode-django-template/master/example.png)

## Using

First, you will need to install Visual Studio Code `0.10`. In the command palette (`cmd-shift-p`) select `Install Extension` and choose `Jinja`.

The downside of the Jinja language is that there is no defined file extension and as such, there is no way to detect it automatically in all cases. This extension will look for it in two file extensions - .html and .j2. The .j2 file extension is heavily used with Ansible which uses the Jinja2 engine underneath.
In the command palette (`ctrl-shift-p`) select `Install Extension` and choose `Django Template`.

## Contributing

Expand Down
13 changes: 13 additions & 0 deletions django-html.configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"comments": {
"blockComment": [
"{% comment %}",
"{% endcomment %}"
]
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
]
}
8 changes: 8 additions & 0 deletions example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends "layout.html" %}
{% block body %}
<ul>
{% for user in users %}
<li><a href="{% url 'user-profile' user.username %}">{{ user.username }}</a></li>
{% endfor %}
</ul>
{% endblock body %}
9 changes: 0 additions & 9 deletions example.j2

This file was deleted.

Binary file modified example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 0 additions & 11 deletions jinja-html.configuration.json

This file was deleted.

10 changes: 0 additions & 10 deletions jinja-yaml.configuration.json

This file was deleted.

10 changes: 0 additions & 10 deletions jinja.configuration.json

This file was deleted.

125 changes: 52 additions & 73 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,74 +1,53 @@
{
"name": "jinja",
"version": "0.0.7",
"publisher": "wholroyd",
"author": {
"name": "William Holroyd"
},
"license": "MIT",
"icon": "icon.png",
"description": "Jinja template language support for Visual Studio Code",
"displayName": "Jinja",
"repository": {
"type": "git",
"url": "https://github.com/wholroyd/vscode-jinja.git"
},
"bugs": {
"url": "https://github.com/wholroyd/vscode-jinja/issues"
},
"categories": [
"Languages",
"Snippets",
"Linters"
],
"engines": {
"vscode": "0.10.x"
},
"contributes": {
"languages": [
{
"id": "jinja",
"aliases": [
"Jinja"
],
"extensions": [".j2"],
"configuration": "./jinja.configuration.json"
},
{
"id": "html",
"aliases": [
"Jinja",
"HTML"
],
"extensions": [".j2", ".html", ".htm"],
"configuration": "./jinja-html.configuration.json"
},
{
"id": "yaml",
"aliases": [
"Jinja",
"YAML"
],
"extensions": [".j2", ".eyaml", ".eyml", ".yaml", ".yml", ".sls"],
"configuration": "./jinja-yaml.configuration.json"
}
],
"grammars": [
{
"language": "jinja",
"scopeName": "source.jinja",
"path": "./syntaxes/jinja.json"
},
{
"language": "html",
"scopeName": "text.html.jinja",
"path": "./syntaxes/jinja-html.json"
},
{
"language": "yaml",
"scopeName": "text.yaml.jinja",
"path": "./syntaxes/jinja-yaml.json"
}
]
}
}
"name": "django-html",
"version": "1.3.0",
"publisher": "bibhasdn",
"author": {
"name": "Bibhas Debnath"
},
"license": "MIT",
"icon": "icon.png",
"description": "Django template language support for Visual Studio Code",
"displayName": "Django Template",
"repository": {
"type": "git",
"url": "https://github.com/iambibhas/vscode-django-template.git"
},
"bugs": {
"url": "https://github.com/iambibhas/vscode-django-template/issues"
},
"categories": [
"Languages",
"Snippets",
"Linters"
],
"engines": {
"vscode": "^1.0.0"
},
"contributes": {
"languages": [
{
"id": "django-html",
"aliases": [
"Django Template"
],
"extensions": [".html", ".htm"],
"configuration": "./django-html.configuration.json"
}
],
"grammars": [
{
"language": "django-html",
"scopeName": "text.html.django",
"path": "./syntaxes/django-html.json"
}
],
"snippets": [
{
"language": "django-html",
"scopeName": "text.html.django",
"path": "./snippets/django-snippets.json"
}
]
}
}
132 changes: 132 additions & 0 deletions snippets/django-snippets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
{
"Comment": {
"prefix": "comment",
"description": "Comment block",
"body": [
"{% comment \"$1\" %}",
"$2",
"{% endcomment %}"
]
},
"var": {
"prefix": "var",
"description": "Empty Var",
"body": [
"{{ $1 }}"
]
},
"tag": {
"prefix": "tag",
"description": "Empty tag",
"body": [
"{% $1 %}"
]
},
"CSRF": {
"prefix": "csrf",
"description": "CSRF token",
"body": [
"{% csrf_token %}"
]
},
"Extends": {
"prefix": "extends",
"description": "Extends block",
"body": [
"{% extends \"$1\" %}"
]
},
"For loop": {
"prefix": "for",
"description": "For loop",
"body": [
"{% for $1 in $2 %}",
"$3",
"{% endfor %}"
]
},
"For-Empty loop": {
"prefix": "forempty",
"description": "For-Empty loop",
"body": [
"{% for $1 in $2 %}",
"$3",
"{% empty %}",
"$4",
"{% endfor %}"
]
},
"If condition": {
"prefix": "if",
"description": "IF condition",
"body": [
"{% if $1 %}",
"$2",
"{% else %}",
"{% endif %}"
]
},
"Include": {
"prefix": "include",
"description": "Include other templates",
"body": [
"{% include \"$1\" %}"
]
},
"Lorem": {
"prefix": "lorem",
"description": "Generate Lorem Text Block",
"body": [
"{% lorem ${how_many_paragraphs} %}"
]
},
"Spaceless": {
"prefix": "spaceless",
"description": "Removes whitespaces in between",
"body": [
"{% spaceless %}",
"$1",
"{% endspaceless %}"
]
},
"Super": {
"prefix": "super",
"description": "Super block",
"body": [
"{{ block.super }}"
]
},
"Template Block": {
"prefix": "block",
"description": "Creates a block",
"body": [
"{% block $1 %}",
"$2",
"{% endblock $1 %}"
]
},
"URL": {
"prefix": "url",
"description": "URL tag",
"body": [
"{% url '${some-url-name}' ${arg} %}"
]
},
"With": {
"prefix": "with",
"description": "With block",
"body": [
"{% with ${local_var}=${context_var} %}",
"$1",
"{% endwith %}"
]
},
"Static": {
"prefix": "static",
"description": "Static file",
"body": [
"{% static '$1' %}"
]
}

}
Loading