Commit f62e3005 by andreas.pelme

Add option to specify custom a template name.

Add a default template for IE conditional comments.

Fix bug #10: The URL was urlquoted bad, causing an absolute MEDIA_URL to be escaped. Only escape filename instead of entire URL.



git-svn-id: https://django-compress.googlecode.com/svn/trunk@44 98d35234-f74b-0410-9e22-51d878bdf110
parent 88749462
<!--[if {{ condition|default:"IE" }}]><link href="{{ url }}" rel="stylesheet" type="text/css" media="{{ media|default:"screen,projection" }}" /><![endif]-->
\ No newline at end of file
<!--[if {{ condition|default:"IE" }}]><script type="text/javascript" src="{{ url }}"></script><![endif]-->
\ No newline at end of file
......@@ -17,7 +17,7 @@ def render_common(template_name, obj, filename):
else:
context = {}
url = urlquote(django_settings.MEDIA_URL + filename)
url = django_settings.MEDIA_URL + urlquote(filename)
if settings.COMPRESS and 'bump_filename' in obj and obj['bump_filename']:
try:
......@@ -32,10 +32,20 @@ def render_common(template_name, obj, filename):
return template.loader.render_to_string(template_name, context)
def render_css(css, filename):
return render_common('compress/css.html', css, filename)
try:
template_name = css['template_name']
except KeyError:
template_name = 'compress/css.html'
return render_common(template_name, css, filename)
def render_js(js, filename):
return render_common('compress/js.html', js, filename)
try:
template_name = js['template_name']
except KeyError:
template_name = 'compress/js.html'
return render_common(template_name, js, filename)
class CompressedCSSNode(template.Node):
def __init__(self, name):
......@@ -98,4 +108,4 @@ def compressed_js(parser, token):
raise template.TemplateSyntaxError, '%r requires exactly one argument, being the name of the COMPRESS_JS setting'
return CompressedJSNode(name)
compressed_js = register.tag(compressed_js)
\ No newline at end of file
compressed_js = register.tag(compressed_js)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment