Skip to main content

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)

Uploaded Source

File details

Details for the file aldryn-snake-0.0.2.tar.gz.

File metadata

File hashes

Hashes for aldryn-snake-0.0.2.tar.gz
Algorithm Hash digest
SHA256 ae89c2f21a64b8868d0440c808a015329f17292d39788bda6c925ae706fc89cb
MD5 35f6081bc4ecd213926b7970f6520546
BLAKE2b-256 50d164e954bb53fc2a6f22cf0dbb9fbd42e7e0452c35d9de1d3b6f50887eea30

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page