Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

django-smartspaceless

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

django-smartspaceless

A Django template tag application for minifying block-level HTML elements only

  • 0.1.2
  • PyPI
  • Socket score

Maintainers
1

Django Smart Spaceless


|PyPI version|_ |Build status|_

.. |PyPI version| image:: https://badge.fury.io/py/django-smartspaceless.svg .. _PyPI version: https://pypi.python.org/pypi/django-smartspaceless

.. |Build status| image:: https://travis-ci.org/richardcornish/django-smartspaceless.svg?branch=master .. _Build status: https://travis-ci.org/richardcornish/django-smartspaceless

Django Smart Spaceless is a Django <https://www.djangoproject.com/>_ template tag <https://docs.djangoproject.com/en/1.11/howto/custom-template-tags/>_ application for minifying block-level HTML elements only.

It's just like |spaceless|, but preserves white space between inline HTML elements. Useful for HTML where spaces directly between <a>, <strong>, and other inline elements is likely desired to be preserved. Packages the django-htmlmin <https://github.com/cobrateam/django-htmlmin> project to be used as a template tag.

.. |spaceless| replace:: spaceless .. _spaceless: https://docs.djangoproject.com/en/1.11/ref/templates/builtins/#spaceless

  • Package distribution <https://pypi.python.org/pypi/django-smartspaceless>_
  • Code repository <https://github.com/richardcornish/django-smartspaceless>_
  • Documentation <https://django-smartspaceless.readthedocs.io/>_
  • Tests <https://travis-ci.org/richardcornish/django-smartspaceless>_

Install

.. code-block:: bash

$ pip install django-smartspaceless

Add to settings.py.

.. code-block:: python

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

Usage

.. code-block:: django

{% load smartspaceless_tags %}

{% smartspaceless %}

Link 1

Link 2 Link 3

{% endsmartspaceless %}

Result:

.. code-block:: html

Link 1

Link 2 Link 3

The space between <a href="#">Link 2</a> and <a href="#">Link 3</a> is preserved. Removing that space would be bad.

Note

Please note that django-htmlmin <https://github.com/cobrateam/django-htmlmin>_ by default uses the html5lib <https://github.com/html5lib/html5lib-python>_ parser, which prepends possibly missing <html><head></head><body> and appends possibly missing </body></html> tags in an effort to create valid HTML. The template tag changes this default behavior to use html.parser <https://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-a-parser>_, the HTML parser in Python's standard library, which does not alter HTML fragments.

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc