Adds header and tail scripts from addons
Project description
Adds tail and head context processors for Addons.
Installation
Add aldryn_snake.template_api.template_processor to your TEMPLATE_CONTEXT_PROCESSORS settings.
Somewhere in your app that will be imported on startup (recommended in models.py) add something to the api:
# -*- coding: utf-8 -*- from aldryn_snake.template_api import registry from django.conf import settings OPTIMIZELY_SCRIPT = """<script src="//cdn.optimizely.com/js/%(account_number)s.js"></script>""" def get_crazyegg_script(): optimizely_number = getattr(settings, 'OPTIMIZELY_ACCOUNT_NUMBER', None) if optimizely_number: return OPTIMIZELY_SCRIPT % {'account_number': optimizely_number} else: return '' registry.add_to_tail(get_crazyegg_script())
If add_to_tail or add_to_head receive a callable, it will be called with the request keyword argument.
Add the following in your base template to the <head>:
{{ ALDRYN_SNAKE.render_head }}
Add the following in your base template right above </body>:
{{ ALDRYN_SNAKE.render_tail }}
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
aldryn-snake-0.0.2.tar.gz
(3.0 kB
view details)
File details
Details for the file aldryn-snake-0.0.2.tar.gz
.
File metadata
- Download URL: aldryn-snake-0.0.2.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae89c2f21a64b8868d0440c808a015329f17292d39788bda6c925ae706fc89cb |
|
MD5 | 35f6081bc4ecd213926b7970f6520546 |
|
BLAKE2b-256 | 50d164e954bb53fc2a6f22cf0dbb9fbd42e7e0452c35d9de1d3b6f50887eea30 |