Skip to content

Commit c3fab9b

Browse files
beniwohlijezdez
authored andcommitted
Use the safe filter for inline content and respect the use of the media attribute on inline style if available.
1 parent 35cd608 commit c3fab9b

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

compressor/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@ def output(self):
152152
return render_to_string(self.template_name, context)
153153

154154
def output_inline(self):
155-
return render_to_string(self.template_name_inline, {'content': settings.COMPRESS and self.combined or self.concat()})
155+
context = {'content': settings.COMPRESS and self.combined or self.concat()}
156+
if hasattr(self, 'extra_context'):
157+
context.extend(self.extra_context)
158+
return render_to_string(self.template_name_inline, context)
156159

157160
class CssCompressor(Compressor):
158161

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<style type="text/css">{{ content }}</style>
1+
<style type="text/css"{% if media %} media="{{ media }}"{% endif %}>{{ content|safe }}</style>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<script type="text/javascript">{{ content }}</script>
1+
<script type="text/javascript">{{ content|safe }}</script>

0 commit comments

Comments
 (0)