Commits

David Chambers committed 95c4664

Updated `Script#__unicode__` and `StyleSheet#__unicode__`. They now return
`SafeData` instances, so applying the `safe` filter is no longer necessary.

Comments (0)

Files changed (6)

+from django.utils.safestring import mark_safe
+
+
 class Script(object):
     def __init__(self, src):
         self.src = src
 
     def __unicode__(self):
-        return u'<script src="%s"></script>' % self.src
+        return mark_safe(u'<script src="%s"></script>' % self.src)
 
 
 class StyleSheet(object):
 
     def __unicode__(self):
         if self.media:
-            return u'<link rel="stylesheet" href="%s" media="%s" />' % (self.href, self.media)
+            text = u'<link rel="stylesheet" href="%s" media="%s" />' % (self.href, self.media)
         else:
-            return u'<link rel="stylesheet" href="%s" />' % self.href
+            text = u'<link rel="stylesheet" href="%s" />' % self.href
+        return mark_safe(text)

templates/_base.dhtml

     <meta charset="utf-8" />
     <title>{% block title %}{{ SITE_TITLE }}{% endblock %}</title>{% block feeds %}
     <link rel="alternate" type="application/atom+xml" href="{% url mango.feeds.atom %}" />{% endblock %}{% for stylesheet in stylesheets %}
-    {{ stylesheet|safe }}{% endfor %}
+    {{ stylesheet }}{% endfor %}
     <!--[if lt IE 9]>
     <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
     <![endif]-->{% endblock %}
     <footer id="footer">{% block footer %}
         <p>Powered by <a href="http://mango.io/">Mango</a></p>{% endblock %}
     </footer>{% block scripts %}{% for script in scripts %}
-    {{ script|safe }}{% endfor %}
+    {{ script }}{% endfor %}
     <script>
         (function () {
 

templates/category.dhtml

 {% load mango_extras %}
 {% block title %}{{ category.name|smart_capfirst }}{% endblock %}
 {% block stylesheets %}{{ block.super }}{% for stylesheet in category.pages|combine:category.posts|required:"stylesheets" %}
-    {{ stylesheet|safe }}{% endfor %}{% endblock %}
+    {{ stylesheet }}{% endfor %}{% endblock %}
 {% block content %}
             <h1>{{ category.name|smart_capfirst }}</h1>
             {% if category.pages %}
             <p>This category is currently empty.</p>{% endif %}
 {% endblock %}
 {% block scripts %}{{ block.super }}{% for script in category.pages|combine:category.posts|required:"scripts" %}
-    {{ script|safe }}{% endfor %}{% endblock %}
+    {{ script }}{% endfor %}{% endblock %}

templates/document.dhtml

 {% block title %}{{ document.title_text }}{% endblock %}
 {% block head %}
     {{ block.super }}{% for stylesheet in document.stylesheets %}
-    {{ stylesheet|safe }}{% endfor %}{% endblock %}
+    {{ stylesheet }}{% endfor %}{% endblock %}
 {% block content %}
                 <article>
                     <header>
 {% endblock %}
 {% block scripts %}
     {{ block.super }}{% for script in document.scripts %}
-    {{ script|safe }}{% endfor %}{% endblock %}
+    {{ script }}{% endfor %}{% endblock %}

templates/index.dhtml

 {% extends "base.dhtml" %}
 {% load mango_extras %}
 {% block stylesheets %}{{ block.super }}{% for stylesheet in posts|slice:":5"|required:"stylesheets" %}
-    {{ stylesheet|safe }}{% endfor %}{% endblock %}
+    {{ stylesheet }}{% endfor %}{% endblock %}
 {% block header_title %}<h1>{{ SITE_TITLE }}</h1>{% endblock %}
 {% block content %}{% for document in posts|slice:":5" %}{% include "excerpt.dhtml" %}{% empty %}
             <h2>Welcome to your new blog</h2>
             <h2>Want more?</h2>
             <p>Check out the <a href="{% url mango.views.archives %}">archives</a>.</p>{% endif %}{% endblock %}
 {% block scripts %}{{ block.super }}{% for script in posts|slice:":5"|required:"scripts" %}
-    {{ script|safe }}{% endfor %}{% endblock %}
+    {{ script }}{% endfor %}{% endblock %}
 {% block title %}Posts tagged "{{ tag }}"{% endblock %}{% block feeds %}{{ block.super }}
     <link rel="alternate" type="application/atom+xml" href="{% url mango.feeds.atom tag %}" />{% endblock %}
 {% block stylesheets %}{{ block.super }}{% for stylesheet in documents|required:"stylesheets" %}
-    {{ stylesheet|safe }}{% endfor %}{% endblock %}
+    {{ stylesheet }}{% endfor %}{% endblock %}
 {% block content %}
             <h1>Posts tagged "{{ tag }}"</h1>{% for document in documents %}{% include "excerpt.dhtml" %}{% empty %}
             <p>There are currently no posts tagged "{{ tag }}".</p>{% endfor %}
 {% endblock %}
 {% block scripts %}{{ block.super }}{% for script in documents|required:"scripts" %}
-    {{ script|safe }}{% endfor %}{% endblock %}
+    {{ script }}{% endfor %}{% endblock %}