<commit_before>require 'breezy_template/breezy_template'

class BreezyTemplate
  class Handler
    cattr_accessor :default_format
    self.default_format = Mime[:js]

    def self.template_id(template)
      template.identifier.sub("#{Rails.root}/app/views/", "").split('.')[0]
    end

    def self.call(template)
      # this juggling is required to keep line numbers right in the error
      %{__already_defined = defined?(json);json||=::BreezyTemplate.new(self);json._set_search_path_once(breezy_filter) if defined?(breezy_filter); json._set_request_url(request.path);#{template.source}
        if !(__already_defined && __already_defined != "method")
          json.merge!({data: json._found! || json.empty! })

          json.set! :screen, '#{self.template_id(template)}'

          if defined?(breezy) && breezy
            breezy.each do |k, v|
              json.set! k, v
            end
          end

          if protect_against_forgery?
            json.csrf_token form_authenticity_token
          end

          __sprockets_assets = (::BreezyTemplate.configuration.track_sprockets_assets || []).map do |asset|
            asset_path(asset)
          end

          __pack_assets = []
          if defined?(asset_pack_path)
            __pack_assets = (::BreezyTemplate.configuration.track_pack_assets || []).map do |asset|
              asset_pack_path(asset)
            end
          end

          if __sprockets_assets.any? || __pack_assets.any?
            json.assets (__sprockets_assets + __pack_assets)
          end

          if defined?(breezy_filter) && !!breezy_filter
            json.action 'graft'
            json.path breezy_filter
          end

          json.joints ::BreezyTemplate::Var.new('joints')
          json.defers ::BreezyTemplate::Var.new('defers')

          json.target!
        end
      }
    end
  end
end<commit_msg>Fix: the returned filter needs to be camelized lower<commit_after>require 'breezy_template/breezy_template'

class BreezyTemplate
  class Handler
    cattr_accessor :default_format
    self.default_format = Mime[:js]

    def self.template_id(template)
      template.identifier.sub("#{Rails.root}/app/views/", "").split('.')[0]
    end

    def self.call(template)
      # this juggling is required to keep line numbers right in the error
      %{__already_defined = defined?(json);json||=::BreezyTemplate.new(self);json._set_search_path_once(breezy_filter) if defined?(breezy_filter); json._set_request_url(request.path);#{template.source}
        if !(__already_defined && __already_defined != "method")
          json.merge!({data: json._found! || json.empty! })

          json.set! :screen, '#{self.template_id(template)}'

          if defined?(breezy) && breezy
            breezy.each do |k, v|
              json.set! k, v
            end
          end

          if protect_against_forgery?
            json.csrf_token form_authenticity_token
          end

          __sprockets_assets = (::BreezyTemplate.configuration.track_sprockets_assets || []).map do |asset|
            asset_path(asset)
          end

          __pack_assets = []
          if defined?(asset_pack_path)
            __pack_assets = (::BreezyTemplate.configuration.track_pack_assets || []).map do |asset|
              asset_pack_path(asset)
            end
          end

          if __sprockets_assets.any? || __pack_assets.any?
            json.assets (__sprockets_assets + __pack_assets)
          end

          if defined?(breezy_filter) && !!breezy_filter
            json.action 'graft'
            __formatter = ::BreezyTemplate::KeyFormatter.new({camelize: :lower})
            json.path breezy_filter
              .split('.')
              .map {|part|
                if part.include? '='
                  k, v = parts.split('=')
                  [__formatter.format(k),'=', v].join('=')
                else
                  __formatter.format(part)
                end
              }
              .join('.')
          end

          json.joints ::BreezyTemplate::Var.new('joints')
          json.defers ::BreezyTemplate::Var.new('defers')

          json.target!
        end
      }
    end
  end
end
{'fraction_non_alphanumeric': 0.11302681992337164, 'fraction_numerical': 0.0004789272030651341, 'mean_word_length': 2.1524528301886794, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5517921', 'n_tokens_mistral': 1280, 'n_tokens_neox': 1250, 'n_words': 230}