lib/nanoc/helpers/capturing.rb in nanoc-3.3.2 vs lib/nanoc/helpers/capturing.rb in nanoc-3.3.3

- old
+ new

@@ -37,13 +37,10 @@ module Capturing # @api private class CapturesStore - require 'singleton' - include Singleton - def initialize @store = {} end def []=(item, name, content) @@ -56,10 +53,19 @@ @store[item.identifier][name] end end + class ::Nanoc::Site + + # @api private + def captures_store + @captures_store ||= CapturesStore.new + end + + end + # @overload content_for(name, &block) # # Captures the content inside the block and stores it so that it can be # referenced later on. The same method, {#content_for}, is used for # getting the captured content as well as setting it. When capturing, @@ -94,21 +100,21 @@ end name = args[0] # Capture and store content = capture(&block) - CapturesStore.instance[@item, name.to_sym] = content + @site.captures_store[@item, name.to_sym] = content else # Get content # Get args if args.size != 2 raise ArgumentError, "expected 2 arguments (the item " + "and the name of the capture) but got #{args.size} instead" end item = args[0] name = args[1] # Get content - CapturesStore.instance[item, name.to_sym] + @site.captures_store[item, name.to_sym] end end # Evaluates the given block and returns its contents. The contents of the # block is not outputted.