<commit_before>require "./metal"

module CarbonController
  class Base < Metal
    delegate :params, :request

    def self.layout(layout = nil)
      @@layout ||= layout
    end

    include Head
    include Redirect
    include Session
    include Cookies
    include Flash
    include CarbonController::Callbacks
    include Instrumentation

    def request
      @_request
    end

    def response : CarbonDispatch::Response
      @_response
    end

    macro render_template(template)
      layout = CarbonView::Base.layouts["Layouts::{{ @type.id.gsub(/Controller\+?/, "") }}"].new(controller = self)
      view = CarbonViews::{{ @type.id.gsub(/Controller\+?/, "") }}::{{template.camelcase.id}}.new(controller = self)

      response.body = layout.render(view)
      response.headers["Content-Type"] = "text/html"
    end

    def render_text(text)
      response.body = text.to_slice
      response.headers["Content-Type"] = "text/plain"
    end

    def render_json(object)
      response.body = object.to_json
      response.headers["Content-Type"] = "application/json"
    end
  end
end<commit_msg>fixed render text<commit_after>require "./metal"

module CarbonController
  class Base < Metal
    delegate :params, :request

    def self.layout(layout = nil)
      @@layout ||= layout
    end

    include Head
    include Redirect
    include Session
    include Cookies
    include Flash
    include CarbonController::Callbacks
    include Instrumentation

    def request
      @_request
    end

    def response : CarbonDispatch::Response
      @_response
    end

    macro render_template(template)
      layout = CarbonView::Base.layouts["Layouts::{{ @type.id.gsub(/Controller\+?/, "") }}"].new(controller = self)
      view = CarbonViews::{{ @type.id.gsub(/Controller\+?/, "") }}::{{template.camelcase.id}}.new(controller = self)

      response.body = layout.render(view)
      response.headers["Content-Type"] = "text/html"
    end

    def render_text(text)
      response.body = text
      response.headers["Content-Type"] = "text/plain"
    end

    def render_json(object)
      response.body = object.to_json
      response.headers["Content-Type"] = "application/json"
    end
  end
end
{'fraction_non_alphanumeric': 0.12336195210122006, 'fraction_numerical': 0.0, 'mean_word_length': 2.9535714285714287, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3841379', 'n_tokens_mistral': 663, 'n_tokens_neox': 624, 'n_words': 145}