# File lib/staticmatic/mixins/render.rb, line 13
  def generate_html(source_file, source_dir = '')
    full_file_path = File.join(@src_dir, 'pages', source_dir, "#{source_file}.haml")

    begin
      # clear all scope variables except @staticmatic
      @scope.instance_variables.each do |var|
        @scope.instance_variable_set(var, nil) unless var == ('@staticmatic' || :@staticmatic) 
      end
      html = generate_html_from_template_source(File.read(full_file_path))
  
      @layout = determine_layout(source_dir)
    rescue StaticMatic::TemplateError => e
      raise e # re-raise inline errors
    rescue Exception => e
      raise StaticMatic::TemplateError.new(full_file_path, e)
    end

    html
  end