lib/nanoc/helpers/capturing.rb in nanoc-3.7.4 vs lib/nanoc/helpers/capturing.rb in nanoc-3.7.5

- old
+ new

@@ -1,9 +1,8 @@ # encoding: utf-8 module Nanoc::Helpers - # Provides functionality for “capturing” content in one place and reusing # this content elsewhere. # # 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 @@ -33,14 +32,12 @@ # <div id="sidebar"> # <h3>Summary</h3> # <%= @item[:content_for_summary] || '(no summary)' %> # </div> module Capturing - # @api private class CapturesStore - def initialize @store = {} end def []=(item, name, content) @@ -50,26 +47,23 @@ def [](item, name) @store[item.identifier] ||= {} @store[item.identifier][name] end - end class ::Nanoc::Site - # @api private def captures_store @captures_store ||= CapturesStore.new end # @api private def captures_store_compiled_items require 'set' @captures_store_compiled_items ||= Set.new end - end # @overload content_for(name, &block) # # Captures the content inside the block and stores it so that it can be @@ -125,17 +119,17 @@ Nanoc::NotificationCenter.post(:visit_ended, item) # This is an extremely ugly hack to get the compiler to recompile the # item from which we use content. For this, we need to manually edit # the content attribute to reset it. :( - # FIXME clean this up + # FIXME: clean this up unless @site.captures_store_compiled_items.include? item @site.captures_store_compiled_items << item item.forced_outdated = true item.reps.each do |r| raw_content = item.raw_content - r.content = { :raw => raw_content, :last => raw_content } + r.content = { raw: raw_content, last: raw_content } raise Nanoc::Errors::UnmetDependency.new(r) end end end @@ -167,9 +161,7 @@ erbout_addition = erbout_addition.join if erbout_addition.is_a? Array # Done. erbout_addition end - end - end