🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@rhinostone/swig-django

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rhinostone/swig-django

Django-syntax frontend for the @rhinostone/swig-core template engine. Part of the @rhinostone/swig multi-flavor family.

latest
Source
npmnpm
Version
2.7.3
Version published
Maintainers
1
Created
Source

@rhinostone/swig-django

NPM version Socket Badge

Django Template Language frontend for the @rhinostone/swig-core template engine. Part of the multi-flavor architecture introduced in 2.0.0 — see ROADMAP.md for the release narrative.

Installation

npm install @rhinostone/swig-django

This pulls in @rhinostone/swig-core as a peer dependency, pinned to the matching version. Frontends and the core release in lockstep — do not mix versions.

Basic example

var swig = require('@rhinostone/swig-django');

var out = swig.render('Hello, {{ name|upper }}!', {
  locals: { name: 'world' }
});
// => Hello, WORLD!

Supported surface (as of 2.7.0)

Renders real Django templates — everything below was cross-checked against Django 5.2.

  • Tagsif / elif / else, for / empty (with forloop), block, extends, include, with, autoescape, spaceless, comment, verbatim, cycle, firstof.
  • Variable resolution — Django-faithful attribute / dictionary / index lookup. Callable attributes are auto-called (honoring alters_data / do_not_call_in_templates), numeric indexing works ({{ list.0 }}), and dicts iterate via .keys / .values / .items.
  • Filter arguments — Django colon syntax ({{ value|date:"Y-m-d" }}).
  • Filters — 42 built-ins (add, addslashes, capfirst, center, cut, date, default, default_if_none, divisibleby, escape / e, escapejs, filesizeformat, first, floatformat, force_escape, get_digit, iriencode, join, last, length, linebreaks, linebreaksbr, linenumbers, ljust, lower, make_list, phone2numeric, pluralize, rjust, safe, slice, slugify, striptags, time, title, truncatechars, truncatewords, upper, urlencode, wordcount, wordwrap, yesno). See lib/filters.js for the full list.
  • AsyncrenderFileAsync / compileFileAsync for async loaders, plus renderFile(path, locals, cb) against a loader with async === true.

Explicitly unsupported (parse-time throw or absent)

  • No sandboxed-rendering mode — template source is trusted.
  • {% load %} and custom tag libraries — no code-loading.
  • {% url %}, {% static %}, {% csrf_token %}, {% trans %}, {% blocktrans %} — framework infrastructure, out of scope.
  • No whitespace-control ({%- … -%}) — not part of the Django Template Language.
  • No is tests — Django's is is identity comparison, not Jinja2-style tests.
  • {{ block.super }}, {% for … reversed %}, and one-variable {% for x in dict.items %} are deferred (clear parse-time errors).
  • Deferred filters — dictsort / dictsortreversed, stringformat, random, urlize / urlizetrunc, timesince / timeuntil, unordered_list, json_script, truncatechars_html / truncatewords_html, safeseq, pprint.

Repository

Source: gina-io/swig/packages/swig-django. File issues and PRs at gina-io/swig.

License

MIT. See LICENSE in the monorepo root.

Keywords

template

FAQs

Package last updated on 10 Jun 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts