docs: def _generate_code(self, source):
          """
          Common compilation code shared between precompile() and compile()
  
          :param source:
              The template source as a unicode string
  
          :return:
              A tuple of (function, source_code)
          """
  
          if not isinstance(source, str_class):
              raise PybarsError("Template source must be a unicode string")
  
          tree, (position, _) = self._handlebars(source).apply('template')
  
          self.clean_whitespace(tree)
  
          if debug:
              print('\nAST')
              print('---')
              print(tree)
              print('')
  
          if position < len(source):
              line_num = source.count('\n') + 1
              beginning_of_line = source.rfind('\n', 0, position)
              if beginning_of_line == -1:
                  char_num = position
              else:
                  char_num = position - beginning_of_line
              word = self._extract_word(source, position)
              raise PybarsError("Error at character %s of line %s near %s" % (char_num, line_num, word))
  
          # Ensure the builder is in a clean state - kinda gross
          self._compiler.globals['builder']._reset()
  
          output = self._compiler(tree).apply('compile')[0]
          return output