<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def collect_output(self):
 """ helper function to gather the results of `compile_and_process` on all target files """

        if self.embed:
            if self.concat:
                concat_scripts = [self.compiled_scripts[path]
                                  for path in self.build_order]

                return [self.embed_template_string % '\n'.join(concat_scripts)]
            else:
                return [self.embed_template_string %
                        self.compiled_scripts[path]
                        for path in self.build_order]
        else:
            return [self.external_template_string %
                    os.path.join(
                        self.relative_directory,
                        os.path.relpath(
                            self.out_path_of(path),
                            self.output_directory))

                    for path in self.build_order
                    if self.compiled_scripts[path] != ""]