<commit_before>require 'action_view/helpers/rendering_helper'
require 'action_view/renderer/template_renderer'

ActionView::Helpers::RenderingHelper.module_eval do
  def render_parent_template(locals = {}, &block)
    template = controller.active_template
    view_paths.exclusions << template
    locals["__rendered_depth_#{view_paths.exclusions.count}"] = true
    result = render(:file => template.virtual_path, :locals => locals, &block)
    view_paths.exclusions.delete template
    result
  end

  def render_with_parent(options = {}, locals = {}, &block)
    if options == :parent
      render_parent_template(locals, &block)
    else
      render_without_parent(options, locals, &block)
    end<commit_msg>Fixed issue with rendering of parent templates with several handlers and formats available<commit_after>require 'action_view/helpers/rendering_helper'
require 'action_view/renderer/template_renderer'

ActionView::Helpers::RenderingHelper.module_eval do
  def render_parent_template(locals = {}, &block)
    template = controller.active_template
    view_paths.exclusions << template
    locals["__rendered_depth_#{view_paths.exclusions.count}"] = true
    handlers = ActionView::Template::Handlers.extensions.select do |ext|
      ActionView::Template.handler_for_extension(ext) == template.handler
    end
    result = render(:template => template.virtual_path,
                    :formats => template.formats,
                    :handlers => handlers,
                    :locals => locals, &block)
    view_paths.exclusions.delete template
    result
  end

  def render_with_parent(options = {}, locals = {}, &block)
    if options == :parent
      render_parent_template(locals, &block)
    else
      render_without_parent(options, locals, &block)
    end
{'fraction_non_alphanumeric': 0.10016882386043895, 'fraction_numerical': 0.0, 'mean_word_length': 4.153623188405797, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '6431664', 'n_tokens_mistral': 501, 'n_tokens_neox': 499, 'n_words': 100}