<commit_before># encoding: utf-8

module Nanoc3::Helpers

  # Nanoc3::Helpers::Capturing provides a content_for method, which allows
  # content to be "captured" on one item and reused elsewhere.
  #
  # = Example
  #
  # For example, suppose you want the sidebar of your site to contain a short
  # summary of the item. You could put the summary in the meta file, but
  # that’s not possible when the summary contains eRuby. You could also put
  # the sidebar inside the actual item, but that’s not very pretty. Instead,
  # you write the summary on the item itself, but capture it, and print it in
  # the sidebar layout.
  #
  # Captured content becomes part of the item. For example, a sidebar layout
  # could look like this:
  #
  #   <div id="sidebar">
  #     <h3>Summary</h3>
  #     <%= @item[:content_for_summary] || '(no summary)' %>
  #   </div>
  #
  # To put something inside that content_for_summary variable, capture it
  # using the content_for function. In the about item, for example:
  #
  #   <% content_for :summary do %>
  #     <p>On this item, nanoc is introduced, blah blah.</p>
  #   <% end %>
  #
  # When the site is compiled, the sidebar of the about item will say “On
  # this item, the purpose of nanoc is described, blah blah blah,” as
  # expected.
  #
  # This helper has been tested with ERB and Haml.
  #
  # To activate this helper, +include+ it, like this:
  #
  #   include Nanoc3::Helpers::Capturing
  module Capturing

    # Captures the content inside the block into a item attribute named
    # "content_for_" followed by the given name. The content of the block
    # itself will not be outputted.
    def content_for(name, &block)
      eval("@item[:content_for_#{name.to_s}] = capture(&block)")
    end

    # Evaluates the given block and returns the result. The block is not outputted.
    def capture(*args, &block)
      # Get erbout so far
      erbout = eval('_erbout', block.binding)
      erbout_length = erbout.length

      # Execute block
      block.call(*args)

      # Get new piece of erbout
      erbout_addition = erbout[erbout_length..-1]

      # Remove addition
      erbout[erbout_length..-1] = ''

      # Done
      erbout_addition
    end

  end

end<commit_msg>removed unused args from #capture<commit_after># encoding: utf-8

module Nanoc3::Helpers

  # Nanoc3::Helpers::Capturing provides a content_for method, which allows
  # content to be "captured" on one item and reused elsewhere.
  #
  # = Example
  #
  # For example, suppose you want the sidebar of your site to contain a short
  # summary of the item. You could put the summary in the meta file, but
  # that’s not possible when the summary contains eRuby. You could also put
  # the sidebar inside the actual item, but that’s not very pretty. Instead,
  # you write the summary on the item itself, but capture it, and print it in
  # the sidebar layout.
  #
  # Captured content becomes part of the item. For example, a sidebar layout
  # could look like this:
  #
  #   <div id="sidebar">
  #     <h3>Summary</h3>
  #     <%= @item[:content_for_summary] || '(no summary)' %>
  #   </div>
  #
  # To put something inside that content_for_summary variable, capture it
  # using the content_for function. In the about item, for example:
  #
  #   <% content_for :summary do %>
  #     <p>On this item, nanoc is introduced, blah blah.</p>
  #   <% end %>
  #
  # When the site is compiled, the sidebar of the about item will say “On
  # this item, the purpose of nanoc is described, blah blah blah,” as
  # expected.
  #
  # This helper has been tested with ERB and Haml.
  #
  # To activate this helper, +include+ it, like this:
  #
  #   include Nanoc3::Helpers::Capturing
  module Capturing

    # Captures the content inside the block into a item attribute named
    # "content_for_" followed by the given name. The content of the block
    # itself will not be outputted.
    def content_for(name, &block)
      eval("@item[:content_for_#{name.to_s}] = capture(&block)")
    end

    # Evaluates the given block and returns the result. The block is not outputted.
    def capture(&block)
      # Get erbout so far
      erbout = eval('_erbout', block.binding)
      erbout_length = erbout.length

      # Execute block
      block.call

      # Get new piece of erbout
      erbout_addition = erbout[erbout_length..-1]

      # Remove addition
      erbout[erbout_length..-1] = ''

      # Done
      erbout_addition
    end

  end

end
{'fraction_non_alphanumeric': 0.0889584264640143, 'fraction_numerical': 0.003576218149307108, 'mean_word_length': 2.9185639229422065, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '1340519', 'n_tokens_mistral': 1434, 'n_tokens_neox': 1368, 'n_words': 544}