lib/nanoc3/base/layout.rb in nanoc3-3.1.0a2 vs lib/nanoc3/base/layout.rb in nanoc3-3.1.0a3

- old
+ new

@@ -14,29 +14,42 @@ # @return [Hash] This layout's attributes attr_reader :attributes # @return [String] This layout's identifier, starting and ending with a - # slash + # slash attr_accessor :identifier # @return [Time] The time when this layout was last modified attr_reader :mtime # Creates a new layout. # - # @param [String] content The raw content of this layout. + # @param [String] raw_content The raw content of this layout. # # @param [Hash] attributes A hash containing this layout's attributes. # # @param [String] identifier This layout's identifier. # - # @param [Time, nil] mtime The time when this layout was last modified. - def initialize(raw_content, attributes, identifier, mtime=nil) + # @param [Time, Hash, nil] params_or_mtime Extra parameters for the + # layout, or the time when this layout was last modified (deprecated). + # + # @option params_or_mtime [Time, nil] :mtime (nil) The time when this + # layout was last modified + def initialize(raw_content, attributes, identifier, params_or_mtime=nil) + # Get params and mtime + # TODO [in nanoc 4.0] clean this up + if params_or_mtime.nil? || params_or_mtime.is_a?(Time) + params = {} + @mtime = params_or_mtime + elsif params_or_mtime.is_a?(Hash) + params = params_or_mtime + @mtime = params[:mtime] + end + @raw_content = raw_content @attributes = attributes.symbolize_keys @identifier = identifier.cleaned_identifier - @mtime = mtime end # Requests the attribute with the given key. # # @param [Symbol] key The name of the attribute to fetch.