# File lib/nanoc/base/result_data/item_rep.rb, line 385
    def layout(layout, filter_name, filter_args)
      # Check whether item can be laid out
      raise Nanoc::Errors::CannotLayoutBinaryItem.new(self) if self.binary?

      # Create "pre" snapshot
      if @content[:post].nil?
        snapshot(:pre, :final => true)
      end

      # Create filter
      klass = filter_named(filter_name)
      raise Nanoc::Errors::UnknownFilter.new(filter_name) if klass.nil?
      filter = klass.new(assigns.merge({ :layout => layout }))

      # Visit
      Nanoc::NotificationCenter.post(:visit_started, layout)
      Nanoc::NotificationCenter.post(:visit_ended,   layout)

      begin
        # Notify start
        Nanoc::NotificationCenter.post(:processing_started, layout)
        Nanoc::NotificationCenter.post(:filtering_started,  self, filter_name)

        # Layout
        @content[:last] = filter.setup_and_run(layout.raw_content, filter_args)

        # Create "post" snapshot
        snapshot(:post, :final => false)
      ensure
        # Notify end
        Nanoc::NotificationCenter.post(:filtering_ended,  self, filter_name)
        Nanoc::NotificationCenter.post(:processing_ended, layout)
      end
    end