Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

A Django template filter to convert ASCII punctuation into typographic punctuation HTML entities.

Project description

PyPI version

Django Smarty is a Django template filter application to convert ASCII punctuation characters into smart typographic punctuation HTML entities with SmartyPants. Uses the Python smartypants package.

Install

$ pipenv install django-smarty

Add to settings.py.

INSTALLED_APPS = [
    # ...
    'smarty',
]

Usage

{% load smarty_tags %}

{{ post.body|smarty }}

Result:

“Hello—world!”

Settings

smarty is a filter composed of several smaller filters:

  • smartypants is the original SmartyPants
  • smartycaps wraps capital letters in <span class="initialism"></span>

One can apply any filter individually. For example, if one preferred the original SmartyPants, write {{ post.body|smartypants }}.

One can customize the application and order of smarty filters with the SMARTY_FILTERS setting. By default, the SMARTY_FILTERS setting is:

SMARTY_FILTERS = [
    'smartypants',
    'smartycaps',
]

One can also customize the HTML class of smartycaps with the SMARTY_CAPS_CLASS setting. By default, the SMARTY_CAPS_CLASS setting is:

SMARTY_CAPS_CLASS = 'initialism'

Download files

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

Files for django-smarty, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size django_smarty-0.1.3-py2.py3-none-any.whl (5.9 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size django-smarty-0.1.3.tar.gz (4.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page