diff --git a/colab/proxy/templates/proxy/menu_template.html b/colab/proxy/templates/proxy/menu_template.html
new file mode 100644
index 0000000..226a95e
--- /dev/null
+++ b/colab/proxy/templates/proxy/menu_template.html
@@ -0,0 +1,10 @@
+{% for title, links in menu_links.items %}
+
+ {{ title }}
+
+
+{% endfor %}
diff --git a/colab/proxy/templatetags/proxy.py b/colab/proxy/templatetags/proxy.py
index 1b4d2d7..9b83a34 100644
--- a/colab/proxy/templatetags/proxy.py
+++ b/colab/proxy/templatetags/proxy.py
@@ -2,22 +2,10 @@
from django.core.urlresolvers import reverse
from django import template
from django.core.cache import cache
+from django.template.loader import render_to_string
register = template.Library()
-PROXY_MENU_TEMPLATE = """
-
- {title}
-
-
-"""
-
-PROXY_MENU_ITEM_TEMPLATE = """
- {link_title}
-"""
-
@register.simple_tag(takes_context=True)
def proxy_menu(context):
@@ -53,14 +41,8 @@ def proxy_menu(context):
url = reverse(app.label, args=(link,))
menu_links[title].append((text, url))
- menu = ''
-
- for title, links in menu_links.items():
- items = ''
- for text, link in links:
- items += PROXY_MENU_ITEM_TEMPLATE.format(link=link,
- link_title=unicode(text))
- menu += PROXY_MENU_TEMPLATE.format(title=unicode(title), items=items)
+ menu = render_to_string('proxy/menu_template.html',
+ {'menu_links': menu_links})
cache.set(cache_key, menu)
return menu
--
libgit2 0.21.2