Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to format_html function #1

Open
wants to merge 3 commits into
base: feature/django19
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion djangojs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Django.js provide better integration of javascript into Django.
'''

__version__ = '0.9.2.dev'
__version__ = '0.9.3.dev'
__description__ = "Django JS Tools"

#: Packaged jQuery version
Expand Down
10 changes: 5 additions & 5 deletions djangojs/templatetags/js.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django import template
from django.contrib.staticfiles.storage import staticfiles_storage
from django.utils import six
from django.utils.html import mark_safe
from django.utils.html import mark_safe, format_html, format_html_join

from djangojs import JQUERY_MIGRATE_VERSION
from djangojs.conf import settings
Expand Down Expand Up @@ -113,9 +113,9 @@ def javascript(filename, type='text/javascript'):
'''A simple shortcut to render a ``script`` tag to a static javascript file'''
if '?' in filename and len(filename.split('?')) is 2:
filename, params = filename.split('?')
return mark_safe('<script type="%s" src="%s?%s"></script>' % (type, staticfiles_storage.url(filename), params))
return format_html('<script type="{}" src="{}?{}"></script>', type, staticfiles_storage.url(filename), params)
else:
return mark_safe('<script type="%s" src="%s"></script>' % (type, staticfiles_storage.url(filename)))
return format_html('<script type="{}" src="{}"></script>', type, staticfiles_storage.url(filename))


@register.simple_tag
Expand All @@ -139,7 +139,7 @@ def coffee(filename):
@register.simple_tag
def css(filename):
'''A simple shortcut to render a ``link`` tag to a static CSS file'''
return mark_safe('<link rel="stylesheet" type="text/css" href="%s" />' % staticfiles_storage.url(filename))
return format_html('<link rel="stylesheet" type="text/css" href="{}" />', staticfiles_storage.url(filename))


def _boolean(value):
Expand All @@ -161,7 +161,7 @@ def jquery_js(version=None, migrate=False):
libs = [js_lib('jquery-%s%s.js' % (version, suffix))]
if _boolean(migrate):
libs.append(js_lib('jquery-migrate-%s%s.js' % (JQUERY_MIGRATE_VERSION, suffix)))
return mark_safe('\n'.join(libs))
return format_html_join('\n', '{}', ((l, ) for l in libs))


@register.inclusion_tag('djangojs/django_js_tag.html', takes_context=True)
Expand Down