<commit_before>module SidebarHelper
  def render_sidebars
    this_blog.sidebars.inject('') do |acc, sb|
      @sidebar = sb
      sb.parse_request(contents, params)
      controller.response.lifetime = sb.lifetime if sb.lifetime
      acc + render_sidebar(sb)
    end
  end

  def render_sidebar(sidebar)
    if sidebar.view_root
      # Allow themes to override sidebar views
      view_root = File.expand_path(sidebar.view_root)
      rails_root = File.expand_path(RAILS_ROOT)
      if view_root =~ /^#{Regexp.escape(rails_root)}/
        new_root = view_root[rails_root.size..-1]
        new_root.sub! %r{^/?vendor/}, ""
        new_root.sub! %r{/views}, ""
        new_root = File.join(this_blog.current_theme.path, "views", new_root)
        view_root = new_root if File.exists?(File.join(new_root, "content.rhtml"))
      end
      render_to_string(:file => "#{view_root}/content.rhtml",
                       :locals => sidebar.to_locals_hash)
    else<commit_msg>Tweaked 'render_sidebars' to allow for passing optional sidebar objects.  This should make it easier for theme writers who want to design with  multiple sidebars.<commit_after>module SidebarHelper
  def render_sidebars(*sidebars)
    (sidebars.blank? ? this_blog.sidebars : sidebars).inject('') do |acc, sb|
      @sidebar = sb
      sb.parse_request(contents, params)
      controller.response.lifetime = sb.lifetime if sb.lifetime
      acc + render_sidebar(sb)
    end
  end

  def render_sidebar(sidebar)
    if sidebar.view_root
      # Allow themes to override sidebar views
      view_root = File.expand_path(sidebar.view_root)
      rails_root = File.expand_path(RAILS_ROOT)
      if view_root =~ /^#{Regexp.escape(rails_root)}/
        new_root = view_root[rails_root.size..-1]
        new_root.sub! %r{^/?vendor/}, ""
        new_root.sub! %r{/views}, ""
        new_root = File.join(this_blog.current_theme.path, "views", new_root)
        view_root = new_root if File.exists?(File.join(new_root, "content.rhtml"))
      end
      render_to_string(:file => "#{view_root}/content.rhtml",
                       :locals => sidebar.to_locals_hash)
    else
{'fraction_non_alphanumeric': 0.11558259241927936, 'fraction_numerical': 0.0009358914365933552, 'mean_word_length': 3.0263653483992465, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1437335', 'n_tokens_mistral': 708, 'n_tokens_neox': 692, 'n_words': 140}