Skip to content

Feature: Add Missing Core Django Template Snippets #45

Description

@EndlessTrax

Problem

Several high-frequency, essential Django template tags are missing from django-snippets.json.

Solution

Add the following snippets to snippets/django-snippets.json:

  • ptd-csrf ({% csrf_token %}): Necessary for form post submissions.
  • ptd-sup ({{ block.super }}): Used to access parent block contents.
  • ptd-com ({% comment "note" %}...{% endcomment %}): Multi-line Django comments.
  • ptd-ver ({% verbatim %}...{% endverbatim %}): Escapes Django rendering for JS frameworks (Vue/React).
  • ptd-trans ({% translate "..." %}): Internationalization helper.
  "Django - CSRF Token": {
    "scope": "html",
    "prefix": "ptd-csrf",
    "body": ["{% csrf_token %}$0"],
    "description": "Adds CSRF Token block"
  },
  "Django - Block Super": {
    "scope": "html",
    "prefix": "ptd-sup",
    "body": ["{{ block.super }}$0"],
    "description": "Access parent block content"
  },
  "Django - Comment Block": {
    "scope": "html",
    "prefix": "ptd-com",
    "body": [
      "{% comment \"$1\" %}",
      "\t$0",
      "{% endcomment %}"
    ],
    "description": "Adds Django comment block"
  },
  "Django - Verbatim Block": {
    "scope": "html",
    "prefix": "ptd-ver",
    "body": [
      "{% verbatim %}",
      "\t$0",
      "{% endverbatim %}"
    ],
    "description": "Prevents Django from rendering contents (useful for JS frameworks)"
  },
  "Django - Translate": {
    "scope": "html",
    "prefix": "ptd-trans",
    "body": ["{% translate \"$1\" %}$0"],
    "description": "Translate string"
  }

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions