Skip to content

Commit

Permalink
Merge pull request #17 from quantum5/patch-1
Browse files Browse the repository at this point in the history
Mark inlinei18n output as safe
  • Loading branch information
Sébastien Fievet committed Aug 20, 2016
2 parents 2876795 + fb64982 commit 353781e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/statici18n/templatetags/statici18n.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import absolute_import
import os
from django import template
from django.utils.safestring import mark_safe

try:
from django.contrib.staticfiles.templatetags.staticfiles import static
Expand Down Expand Up @@ -41,4 +42,4 @@ def inlinei18n(locale):
Behind the scenes, this is a thin wrapper around staticfiles's configred
storage
"""
return staticfiles_storage.open(get_path(locale)).read()
return mark_safe(staticfiles_storage.open(get_path(locale)).read())
3 changes: 2 additions & 1 deletion tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ def test_statici18n_templatetag():
def test_inlinei18n_templatetag():
template = """
{% load statici18n %}
<script src="{% inlinei18n LANGUAGE_CODE %}"></script>
<script>{% inlinei18n LANGUAGE_CODE %}</script>
"""
management.call_command('compilejsi18n')
template = get_template_from_string(template)
rendered = template.render(Context({'LANGUAGE_CODE': 'fr'})).strip()
assert 'var django = globals.django || (globals.django = {});' in rendered
assert '&quot;' not in rendered

0 comments on commit 353781e

Please sign in to comment.