Skip to content

Commit

Permalink
Switch to template tag for head block
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem committed Apr 10, 2012
1 parent b7ba307 commit 944450d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
5 changes: 0 additions & 5 deletions example/livembtiles/default_settings.py
Expand Up @@ -108,11 +108,6 @@
'django.contrib.messages.middleware.MessageMiddleware',
)

TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.static',
)


ROOT_URLCONF = 'livembtiles.urls'

TEMPLATE_DIRS = (
Expand Down
2 changes: 1 addition & 1 deletion example/livembtiles/templates/map.html
Expand Up @@ -3,7 +3,7 @@

{% block head %}
{{ block.super }}
{% include "mbtilesmap/head.html" %}
{% mbtilesmap_head %}
{% endblock head %}

{% block body %}
Expand Down
11 changes: 8 additions & 3 deletions mbtilesmap/templatetags/mbtilesmap_tags.py
@@ -1,12 +1,17 @@
from django import template
from django.conf import settings

from mbtilesmap.models import MBTiles


register = template.Library()


@register.simple_tag
def mbtilesmap_head():
c = template.Context()
return template.loader.get_template('mbtilesmap/head.html').render(c)


class MapNode(template.Node):
def __init__(self, name):
self.name = template.Variable(name)
Expand All @@ -15,10 +20,10 @@ def __init__(self, name):
def render(self, context):
name = self.name.resolve(context)
self.mbtiles = MBTiles(name)

t = template.loader.get_template('mbtilesmap/map.html')

c = template.Context({'map': self.mbtiles},
c = template.Context({'map': self.mbtiles},
autoescape=context.autoescape)
return t.render(c)

Expand Down

0 comments on commit 944450d

Please sign in to comment.