Class: Nanoc::PostCompileItemRepView

Inherits:
ItemRepView show all
Defined in:
lib/nanoc/base/views/post_compile_item_rep_view.rb

Instance Method Summary collapse

Methods inherited from ItemRepView

#==, #eql?, #hash, #inspect, #item, #name, #path

Methods inherited from View

#frozen?, #inspect

Instance Method Details

#compiled_content(snapshot: nil) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/nanoc/base/views/post_compile_item_rep_view.rb', line 3

def compiled_content(snapshot: nil)
  if unwrap.binary?
    raise Nanoc::Int::Errors::CannotGetCompiledContentOfBinaryItem.new(unwrap)
  end

  snapshot_contents = @context.compilation_context.compiled_content_cache[unwrap]
  snapshot_name = snapshot || (snapshot_contents[:pre] ? :pre : :last)

  if snapshot_contents[snapshot_name]
    snapshot_contents[snapshot_name].string
  else
    raise Nanoc::Int::Errors::NoSuchSnapshot.new(unwrap, snapshot_name)
  end
end