@@ -156,21 +156,42 @@ def render_string_to_file(
156156 self .buffered_writer .close ()
157157
158158 def apply_template (self , template_abs_path , template , data , output_file ):
159+
160+ # render the content
159161 rendered_content = self .engine .apply_template (
160162 template , data , output_file
161163 )
164+
165+ # convert to utf8 if not already
162166 if not isinstance (rendered_content , bytes ):
163167 rendered_content = rendered_content .encode ("utf-8" )
164168
169+ # attempt to output to the file and printing to stdout instead
170+ # if not found
165171 try :
172+
173+ # check if any of the files have changed
166174 flag = HASH_STORE .is_file_changed (
167175 output_file , rendered_content , template_abs_path
168176 )
177+
178+ # if they have re-render things
169179 if flag :
180+
181+ # write the content to the output file
170182 self .buffered_writer .write_file_out (
171183 output_file , rendered_content
172184 )
173- if not file_system .is_zip_alike_url (output_file ):
185+
186+ # attempt to copy the file permissions of the template
187+ # file to the output file
188+
189+ # if it isn't an archive proceed or stdout
190+ if (
191+ not file_system .is_zip_alike_url (output_file )
192+ and output_file != "-"
193+ ):
194+
174195 try :
175196 file_system .file_permissions_copy (
176197 template_abs_path , output_file
0 commit comments