@@ -54,29 +54,66 @@ def render(self, context):
54
54
pass
55
55
56
56
def render_compressed (self , package , package_name , package_type ):
57
+ """Render HTML for the package.
58
+
59
+ If ``PIPELINE_ENABLED`` is ``True``, this will render the package's
60
+ output file (using :py:meth:`render_compressed_output`). Otherwise,
61
+ this will render the package's source files (using
62
+ :py:meth:`render_compressed_sources`).
63
+
64
+ Subclasses can override this method to provide custom behavior for
65
+ determining what to render.
66
+ """
57
67
if settings .PIPELINE_ENABLED :
58
- method = getattr ( self , "render_{0}" . format ( package_type ))
59
- return method ( package , package . output_filename )
68
+ return self . render_compressed_output ( package , package_name ,
69
+ package_type )
60
70
else :
61
- if settings .PIPELINE_COLLECTOR_ENABLED :
62
- default_collector .collect (self .request )
71
+ return self .render_compressed_sources (package , package_name ,
72
+ package_type )
73
+
74
+ def render_compressed_output (self , package , package_name , package_type ):
75
+ """Render HTML for using the package's output file.
76
+
77
+ Subclasses can override this method to provide custom behavior for
78
+ rendering the output file.
79
+ """
80
+ method = getattr (self , 'render_{0}' .format (package_type ))
81
+
82
+ return method (package , package .output_filename )
83
+
84
+ def render_compressed_sources (self , package , package_name , package_type ):
85
+ """Render HTML for using the package's list of source files.
63
86
64
- packager = Packager ()
65
- method = getattr (self , "render_individual_{0}" .format (package_type ))
87
+ Each source file will first be collected, if
88
+ ``PIPELINE_COLLECTOR_ENABLED`` is ``True``.
89
+
90
+ If there are any errors compiling any of the source files, an
91
+ ``SHOW_ERRORS_INLINE`` is ``True``, those errors will be shown at
92
+ the top of the page.
93
+
94
+ Subclasses can override this method to provide custom behavior for
95
+ rendering the source files.
96
+ """
97
+ if settings .PIPELINE_COLLECTOR_ENABLED :
98
+ default_collector .collect (self .request )
99
+
100
+ packager = Packager ()
101
+ method = getattr (self , 'render_individual_{0}' .format (package_type ))
102
+
103
+ try :
104
+ paths = packager .compile (package .paths )
105
+ except CompilerError as e :
106
+ if settings .SHOW_ERRORS_INLINE :
107
+ method = getattr (self , 'render_error_{0}' .format (
108
+ package_type ))
66
109
67
- try :
68
- paths = packager .compile (package .paths )
69
- except CompilerError as e :
70
- if settings .SHOW_ERRORS_INLINE :
71
- method = getattr (self , 'render_error_{0}' .format (
72
- package_type ))
110
+ return method (package_name , e )
111
+ else :
112
+ raise
73
113
74
- return method (package_name , e )
75
- else :
76
- raise
114
+ templates = packager .pack_templates (package )
77
115
78
- templates = packager .pack_templates (package )
79
- return method (package , paths , templates = templates )
116
+ return method (package , paths , templates = templates )
80
117
81
118
def render_error (self , package_type , package_name , e ):
82
119
return render_to_string ('pipeline/compile_error.html' , Context ({
0 commit comments