
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
django-spaceless-templates
Advanced tools
Django application, providing simple template loader. It reduces HTML output in templates by stripping out whitespace
characters between HTML and django template tags. With cached template loader, whitespace stripping is done only once
during template compilation. This is more efficient than solutions based on {% spaceless %}
tag or middleware minification.
This package is based on following unmaintained packages:
Django template minifying loader <https://github.com/SectorLabs/django-template-minifying-loader>
_Django template minified <https://github.com/iRynek/django-template-minifier>
_How much bandwidth does it save? Check data from real project:
================ ======== ================= Normal HTML 109kB 15kB gzipped Spaceless HTML 67kB 13kB gzipped Saved 38 % 12 % gzipped ================ ======== =================
.. code-block:: bash
pip install django-spaceless-templates
Modify Your Django project settings's module.
For production (note cached loader):
.. code-block:: python
TEMPLATES = [ { 'DIRS': [ str(APPS_DIR.path('templates')), ], 'OPTIONS': { 'loaders': [ ( 'django.template.loaders.cached.Loader', [ 'django_spaceless_templates.loaders.filesystem.Loader', 'django_spaceless_templates.loaders.app_directories.Loader', ], ), ], }, }, ]
For development (each refresh reloads template):
.. code-block:: python
TEMPLATES = [ { 'DIRS': [ str(APPS_DIR.path('templates')), ], 'OPTIONS': { 'loaders': [ 'django_spaceless_templates.loaders.filesystem.Loader', 'django_spaceless_templates.loaders.app_directories.Loader', ], }, }, ]
Using modified settings You can:
.. code-block:: python
TEMPLATE_MINIFIER_FILENAME_EXTENSIONS = ('.html', '.htm', )
.. code-block:: python
TEMPLATE_MINIFIER_EXCLUDED_DIRS = ('admin/', )
.. code-block:: python
TEMPLATE_MINIFIER = False # default = True
.. code-block:: python
TEMPLATE_MINIFIER_STRIP_FUNCTION = 'template_minifier.utils.strip_spaces_in_template'
.. code-block:: python
if DEBUG: TEMPLATE_MINIFIER = False
//
one line comments in your inline javascript <script>
tags. Use / / instead:.. code-block:: js
// comment something - !!it's evil!! and cause the rest of JS code is commented out. function name() { }
/* comment something - it's nice and clean <3! */ function name() { }
{% blockquote %}
without parameter trimmed <https://docs.djangoproject.com/en/2.1/topics/i18n/translation/#blocktrans-template-tag>
_.
Otherwise your blockquote translations won't be translated. Correct usage:.. code-block:: python
{% blockquote trimmed %}
My paragraph...
{% blockquote %}
{{ " " }}
:.. code-block:: html
<div>Text {{ " " }} {{ variable }}</div>
::
(myenv) $ pip install -e .
(myenv) $ python ./runtests.py
.. code-block:: bash
python -m build; python -m twine check dist/*
FAQs
Simple Django template loader that minifies html output.
We found that django-spaceless-templates demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.