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!

Wrapping template tag for django

Project Description

Wrapping template tag for django

Documentation

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.

Example:

from django import template
register = template.Library()

@wrapper_tag.register_tag(register)
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 argument.name not in data:
            return
        return ' title="{title}"'.format(data[argument.name])

And then simply use tag in template:

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

This will yield to:

<div title="Some informational title">
    Content
</div>

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

Quickstart

Install wrapper_tag:

pip install django-wrapper-tag

Then use it in a project:

INSTALLED_APPS = (
    'wrapper_tag',
)

Features

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 runtests.py

Credits

Tools used in rendering this package:

History

0.1.0 (2016-09-29)

  • First release on PyPI.
Release History

Release History

This version
History Node

0.1.17

History Node

0.1.16

History Node

0.1.15

History Node

0.1.14

History Node

0.1.13

History Node

0.1.12

History Node

0.1.11

History Node

0.1.10

History Node

0.1.9

History Node

0.1.8

History Node

0.1.7

History Node

0.1.6

History Node

0.1.5

History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

History Node

0.1.1

History Node

0.1.0

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_wrapper_tag-0.1.17-py2.py3-none-any.whl (25.8 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Oct 6, 2016
django-wrapper-tag-0.1.17.tar.gz (19.8 kB) Copy SHA256 Checksum SHA256 Source Oct 6, 2016

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