Skip to main content

Wrapping template tag for django

Project description

Wrapping template tag for django


Wrapper tag provides base class for wrapping tag. Wrapping tag which can have defined keyword arguments, keyword arguments group in declarative way, and provide multiple steps of template rendering.


from django import template
register = template.Library()

class ExampleTag(wrapper_tag.Tag):

    title = wrapper_tag.Keyword(help_text=('title for example tag'))

    class Meta:
        template = "<div{{ title__rendered }}>{{ content }}</div>"

    def render_title(self, argument, data, context):
        if not in data:
        return ' title="{title}"'.format(data[])

And then simply use tag in template:

{% example title="Some informational title" %}
{% end:example %}

This will yield to:

<div title="Some informational title">

That was just a simple eample what wrapper tag can do. It can do much more than that.


Install wrapper_tag:

pip install django-wrapper-tag

Then use it in a project:



Wrapper tag provides multiple features for tag and arguments.

  • Automatically generates documantation about arguments to tag documentation

  • Define tag aliases and automatically register them as tags.

  • Provide custom render method for tag (render_tag)

  • when TEMPLATE_DEBUG is enabled wrapper tag runs validations for callbacks

Tag arguments features:

  • default values for arguments

  • choices for arguments

  • validators for arguments

Running Tests

Does the code actually work?

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install -r requirements_test.txt
(myenv) $ python


Tools used in rendering this package:


0.1.0 (2016-09-29)

  • First release on PyPI.

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-wrapper-tag-0.1.17.tar.gz (19.8 kB view hashes)

Uploaded source

Built Distribution

Supported by

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