Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Uses templates specified by attributes #167

wants to merge 1 commit into from

2 participants


With this change, Compressor's render_content() will use the templates defined in the the template_name and template_name_* properties of the compressor class. That way subclasses can define their own template locations without having to override render_content().

I left the old behavior in as a fallback in case any third parties are implementing custom compressors without template_name* attributes.

@jezdez jezdez closed this in 3995851
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 27, 2011
  1. @matthewwithanm
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 2 deletions.
  1. +9 −2 compressor/
11 compressor/
@@ -267,5 +267,12 @@ def render_output(self, mode, context=None):
final_context = Context(self.context)
post_compress.send(sender=self.__class__, type=self.type,
mode=mode, context=final_context)
- return render_to_string("compressor/%s_%s.html" %
- (self.type, mode), final_context)
+ template_attr = 'template_name'
+ if mode != 'file':
+ template_attr += '_%s' % mode
+ try:
+ template = getattr(self, template_attr)
+ except AttributeError:
+ template = "compressor/%s_%s.html" % (self.type, mode)
+ return render_to_string(template, final_context)
Something went wrong with that request. Please try again.