docs: def build_template(self, mapfile, names, renderer):
          """
          Build source from global and item templates
          """
          AVAILABLE_DUMPS = json.load(open(mapfile, "r"))
  
          manager = self.get_deps_manager(AVAILABLE_DUMPS)
  
          fp = StringIO.StringIO()
  
          for i, item in enumerate(manager.get_dump_order(names), start=1):
              fp = renderer(fp, i, item, manager[item])
  
          if self.dump_other_apps:
              exclude_models = ['-e {0}'.format(app) for app in
                      self.exclude_apps]
              for i, item in enumerate(manager.get_dump_order(names), start=1):
                  for model in manager[item]['models']:
                      if '-e ' not in model:
                          model = "-e {0}".format(model)
                      if model not in exclude_models:
                          exclude_models.append(model)
              fp = renderer(fp, i+1, 'other_apps', {'models': exclude_models,
                                                    'use_natural_key': True})
  
          content = fp.getvalue()
          fp.close()
  
          context = self.get_global_context().copy()
          context.update({'items': content})
  
          return self.base_template.format(**context)