Skip to main content

Mustache template engine for Django 1.8 and newer, with support for Django context processors.

Project description

django-mustache

A straightforward Mustache-powered template engine for Django, extracted from wq.db and updated to support the new template backend infrastructure in Django 1.8 and newer. django-mustache facilitates progressive enhancement by allowing you to share the same templates between Django and an offline-capable JavaScript web app. Combined with a shared URL structure, this approach ensures that each page in your site can be selectively rendered on the server or on the client as needed.

A number of Pystache/Mustache backends for Django exist, though many are outdated. Only this library provides all of the following:

  • Full integration with existing Django context processors like django.template.context_processors.csrf and django.contrib.auth.context_processors.auth.*
  • Full test suite
  • Installable via PyPI
  • Compatible with Django 1.8 and newer

*wq/app.js provides client-side equivalents for these context variables.

Latest PyPI Release Release Notes License GitHub Stars GitHub Forks GitHub Issues

Travis Build Status Python Support Django Support

Usage

pip3 install django-mustache

Configure django-mustache like you would any template backend:

# myproject/settings.py
TEMPLATES = [
    {
        'BACKEND': 'django_mustache.Mustache',
        'DIRS': [ '...' ],
        'APP_DIRS': False,
        'OPTIONS': {
            'context_processors': [ '...' ],
            'partials_dir': 'partials',
            'file_extension': 'html',
        }
    },
    # ...
]

The following configuration options are supported:

  • context_processors: equivalent to the Django template backend setting. The goal is to be able to use the same context processors for both Django and Mustache template backends. (Let us know if you come across any compatibility issues.)
  • partials_dir: If set, django-mustache will check each template directory for a subfolder containing Mustache partial templates. The default partial folder name is 'partials'. Set to False to disable this feature.
  • file_extension: File extension to use when searching for templates and partials. The default is '.html', which should not conflict with existing Django templates as long as completely separate directories are configured for Mustache templates. Django views typically include the extension in the template name - this is taken into account when searching for templates.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-mustache-1.1.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

django_mustache-1.1.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file django-mustache-1.1.1.tar.gz.

File metadata

  • Download URL: django-mustache-1.1.1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.2

File hashes

Hashes for django-mustache-1.1.1.tar.gz
Algorithm Hash digest
SHA256 db81cf771160a38d392687d4558c160cb2aa6f755bb3273737fcc16d92444b2e
MD5 8ab6f8cf056758093248be90f73430e1
BLAKE2b-256 ef0d243b11ed966a864c82bb76651f88de0e3dc32d55cf30b1174c45339dd733

See more details on using hashes here.

File details

Details for the file django_mustache-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: django_mustache-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.2

File hashes

Hashes for django_mustache-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2c2f444ad7eeea56b7d12285cfd1a923141da84968984da28b54c7d1c13f8d03
MD5 8916a5852bc19f994cba9abb2ed545a2
BLAKE2b-256 4a4458396871fad7153be0412499293f03da9a2ac16af05833a669c2972bb802

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page