Skip to main content

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

Project description

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.

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

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-0.1.0.tar.gz (3.4 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-mustache-0.1.0.tar.gz
Algorithm Hash digest
SHA256 15701b2d1e007c7f0b5e4ac70a0b844bc2a4d56e37844257b8952b2ff416c971
MD5 3f4e4786007a51dbd17ae7017e69e69a
BLAKE2b-256 484b386d0e51a23a36751fa070416e69102cf67eea278065e8e1f084144476b6

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