old_contents: import os
  
  from django import template
  register = template.Library()
  
  project_dir = None
  ctx = None
  
  @register.filter
  def templated(template_path):
      if not template_path.endswith(".template"):
          raise Exception("templates must end with .template")
  
      full_path = os.path.join(project_dir, template_path)
      t = template.Template(open(full_path).read())
      c = template.Context(ctx)
      templated = t.render(c).encode('ascii')
  
      new_path = full_path.split(".template")[0]
      open(new_path, 'w').write(templated)
      return new_path
  
new_contents: import os
  
  from django import template
  register = template.Library()
  
  project_dir = None
  ctx = None
  
  @register.filter
  def templated(template_path):
      full_path = os.path.join(project_dir, template_path)
      t = template.Template(open(full_path).read())
      templated = t.render(template.Context(ctx)).encode('ascii')
  
      templated_path = full_path + '.templated'
      open(templated_path, 'w').write(templated)
      return templated_path
  
subject: clean up implementation a little bit by writing to .templated instead of requiring .template extension