Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Block tag decorator for Django templates

Project Description

Analogue for simple_tag django decorator for making block (paired) template tags.

Works like django.template.Library.simple_tag() and based on its code. One different is first argument, that takes all content between {% tagname %} and {% endtagname %}

Installation

pip install django-simple-block-tag

Usage

templatetags.py

from simpleblocktag import simple_block_tag
from django import template

register = template.Library()


@simple_block_tag(register)
def mytag(content, attr1, attr2=None):
    return "{}{}{}".format(attr1, content, attr2)


@simple_block_tag(register, takes_context=True)
def save_as(context, content, var_name):
    context[var_name] = content
    return ""

template.html

{% load templatetags %}

{% save_as "var_name" %}Some Content{% endsave_as %}
{% mytag "foo" "bar" %} {{ var_name|lower }} {% endmytag %}

Output

foo some content bar
Release History

Release History

This version
History Node

0.1.3

History Node

0.1.2

History Node

0.1

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-simple-block-tag-0.1.3.tar.gz (2.8 kB) Copy SHA256 Checksum SHA256 Source Sep 3, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting