Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install pyjade-coffin

How to install pyjade-coffin

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install pyjade-coffin
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.1.0.dev Available View build log
Windows (64-bit)
0.1.0.dev Available View build log
Mac OS X (10.5+)
0.1.0.dev Available View build log
Linux (32-bit)
0.1.0.dev Available View build log
Linux (64-bit)
0.1.0.dev Available View build log
 
License
LICENSE
Lastest release
version 0.1.0.dev on Nov 20th, 2012

Jade and Jinja2 template support for Django using PyJade's Jinja2 extension with Coffin.

PyJade's Django template loader lacks mixin functionality due to the fact Django has no macro support. This package uses Coffin with PyJade's Jinja2 extension to overcome this. It also provides a few fixes/tweaks to make jade's behavior in Django more closely match the native JavaScript jade engine.

What this package does:

  • Registers PyJade's Jinja2 extension with coffin so .jade files are rendered though Jinja2 which gives us mixin support.
  • Add relative path include support by subclassing coffinEnvironment and overriding the join_path method. This matches jade's native JavaScript engine's behavior.
  • Sets Jinja2's autoescape to false which allows HTML escaping to be handled in Jade templates.

Installation

Install Package

Install with pip:

pip install pyjade-coffin
Setup Django

Add coffin and pyjade-coffin to INSTALLED_APPS in settings.py:

INSTALLED_APPS = (
...
    'coffin',
    'pyjade_coffin',
...
)

Usage

Shortcut Render Functions

To render a jade/jinja2 template you can use the render functions in the pyjade_coffin.shortcuts module provides:

  • render_to_response
  • render
  • render_to_string

These functions work just like django.shortcuts' render functions except they render Jade and Jinja2 templates.

NOTE: Jade templates are detected by their file extension so only *.jade files get processed by PyJade.

Here is an example view:

from django.template import RequestContext
from pyjade_coffin.shortcuts import render_to_response


def test_jade(request):
    c = RequestContext(request, {
        'test': ['this', 'is', 'test', 'data'],
        'check': "<em>Autoescape Test</em>",
    })

    return render_to_response('test_page.jade', c)

Subscribe to package updates

Last updated Nov 20th, 2012

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.