code: def get_template(filename_or_string, is_string=False):
      '''
      Gets a jinja2 ``Template`` object for the input filename or string, with caching
      based on the filename of the template, or the SHA1 of the input string.
      '''
  
      # Cache against string sha or just the filename
      cache_key = sha1_hash(filename_or_string) if is_string else filename_or_string
  
      if cache_key in TEMPLATES:
          return TEMPLATES[cache_key]
  
      if is_string:
          # Set the input string as our template
          template_string = filename_or_string
  
      else:
          # Load template data into memory
          with open(filename_or_string, 'r') as file_io:
              template_string = file_io.read()
  
      TEMPLATES[cache_key] = Template(template_string, keep_trailing_newline=True)
      return TEMPLATES[cache_keyf get_template(filename_or_string, is_string=False):
      '''
      Gets a jinja2 ``Template`` object for the input filename or string, with caching
      based on the filename of the template, or the SHA1 of the input string.
      '''
  
      # Cache against string sha or just the filename
      cache_key = sha1_hash(filename_or_string) if is_string else filename_or_string
  
      if cache_key in TEMPLATES:
          return TEMPLATES[cache_key]
  
      if is_string:
          # Set the input string as our template
          template_string = filename_or_string
  
      else:
          # Load template data into memory
          with open(filename_or_string, 'r') as file_io:
              template_string = file_io.read()
  
      TEMPLATES[cache_key] = Template(template_string, keep_trailing_newline=True)
      return TEMPLATES[cache_key]
docs: Gets a jinja2 ``Template`` object for the input filename or string, with caching
      based on the filename of the template, or the SHA1 of the input string.