<commit_before>module Rails
  module MultiBlockHelpers
    module CaptureSectionHelper
      extend ActiveSupport::Concern

      included do
        include SwitchBlock
      end

      def capture_section(section, *args)
        value = nil
        buffer = with_output_buffer { value = yield it_to(section) }
        if string = buffer.presence || value and string.is_a?(String)
          ERB::Util.html_escape string
        end
      end
    end
  end
end<commit_msg>make it possible to get section without passing a block<commit_after>module Rails
  module MultiBlockHelpers
    module CaptureSectionHelper
      extend ActiveSupport::Concern

      included do
        include SwitchBlock
      end

      def capture_section(section, *args)
        value = nil
        result = begin
          buffer = with_output_buffer { value = yield it_to(section) }
          if string = buffer.presence || value and string.is_a?(String)
            string
          end
        rescue NoMethodError
          ''
        end
        result.html_safe
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.051210428305400374, 'fraction_numerical': 0.0, 'mean_word_length': 2.1159420289855073, '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': '6716554', 'n_tokens_mistral': 284, 'n_tokens_neox': 280, 'n_words': 85}