<commit_before># TILT Template
if defined?(Tilt)
  class PetroglyphTemplate < Tilt::Template
    def initialize_engine
      return if defined?(::Petroglyph)
      require_template_library 'petroglyph'
    end

    def prepare
      options = @options.merge(:source_location => file)
      @engine = ::Petroglyph::Engine.new(data, options)
    end

    def evaluate(scope, locals, &block)
      @engine.render(scope, locals, &block)
    end
  end

  Tilt.register 'pg', PetroglyphTemplate
end

# Rails 2.X Template
if defined?(Rails) && Rails.version =~ /^2/
  require 'action_view/base'
  require 'action_view/template'

  module ActionView
    module TemplateHandlers
      class PetroglyphHandler < TemplateHandler
        include Compilable

        def compile(template) %{
          ::Petroglyph::Engine.new(#{template.source.inspect}).
            render(self, assigns.merge(local_assigns))
        } end
      end
    end
  end

  ActionView::Template.register_template_handler :pg, ActionView::TemplateHandlers::PetroglyphHandler
end

# Rails 3.X Template
if defined?(Rails) && Rails.version =~ /^3/
  module ActionView
    module Template::Handlers
      class Petroglyph

        def self.call(template)
          source = if template.source.empty?
            File.read(template.identifier)
          else # use source
            template.source
          end

          %{ ::Petroglyph::Engine.new(#{source.inspect}).
              render(self, assigns.merge(local_assigns)) }
        end # call
      end # petroglyph class
    end # handlers
  end

  ActionView::Template.register_template_handler :pg, ActionView::Template::Handlers::Petroglyph
end<commit_msg>Fix partials for Rails<commit_after># TILT Template
if defined?(Tilt)
  class PetroglyphTemplate < Tilt::Template
    def initialize_engine
      return if defined?(::Petroglyph)
      require_template_library 'petroglyph'
    end

    def prepare
      options = @options.merge(:source_location => file)
      @engine = ::Petroglyph::Engine.new(data, options)
    end

    def evaluate(scope, locals, &block)
      @engine.render(scope, locals, &block)
    end
  end

  Tilt.register 'pg', PetroglyphTemplate
end

# Rails 2.X Template
if defined?(Rails) && Rails.version =~ /^2/
  require 'action_view/base'
  require 'action_view/template'

  module ActionView
    module TemplateHandlers
      class PetroglyphHandler < TemplateHandler
        include Compilable

        def compile(template) %{
          ::Petroglyph::Engine.new(#{template.source.inspect}).
            render(self, assigns.merge(local_assigns), template.filename)
        } end
      end
    end
  end

  ActionView::Template.register_template_handler :pg, ActionView::TemplateHandlers::PetroglyphHandler
end

# Rails 3.X Template
if defined?(Rails) && Rails.version =~ /^3/
  module ActionView
    module Template::Handlers
      class Petroglyph

        def self.call(template)
          source = if template.source.empty?
            File.read(template.identifier)
          else # use source
            template.source
          end

          %{ ::Petroglyph::Engine.new(#{source.inspect}).
              render(self, assigns.merge(local_assigns), template.identifier) }
        end # call
      end # petroglyph class
    end # handlers
  end

  ActionView::Template.register_template_handler :pg, ActionView::Template::Handlers::Petroglyph
end
{'fraction_non_alphanumeric': 0.0993241257713782, 'fraction_numerical': 0.0023508668821627977, 'mean_word_length': 2.948955916473318, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '3596036', 'n_tokens_mistral': 1006, 'n_tokens_neox': 998, 'n_words': 224}