Class: Nanoc::Core::ViewContextForCompilation
- Inherits:
-
Object
- Object
- Nanoc::Core::ViewContextForCompilation
- Includes:
- ContractsSupport
- Defined in:
- lib/nanoc/core/view_context_for_compilation.rb
Instance Attribute Summary collapse
-
#compilation_context ⇒ Object
readonly
Returns the value of attribute compilation_context.
-
#compiled_content_store ⇒ Object
readonly
Returns the value of attribute compiled_content_store.
-
#dependency_tracker ⇒ Object
readonly
Returns the value of attribute dependency_tracker.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#reps ⇒ Object
readonly
Returns the value of attribute reps.
Instance Method Summary collapse
- #assigns_for(rep, site:) ⇒ Object
-
#initialize(reps:, items:, dependency_tracker:, compilation_context:, compiled_content_store:) ⇒ ViewContextForCompilation
constructor
A new instance of ViewContextForCompilation.
Methods included from ContractsSupport
enabled?, included, setup_once, warn_about_performance
Constructor Details
#initialize(reps:, items:, dependency_tracker:, compilation_context:, compiled_content_store:) ⇒ ViewContextForCompilation
Returns a new instance of ViewContextForCompilation.
21 22 23 24 25 26 27 |
# File 'lib/nanoc/core/view_context_for_compilation.rb', line 21 def initialize(reps:, items:, dependency_tracker:, compilation_context:, compiled_content_store:) @reps = reps @items = items @dependency_tracker = dependency_tracker @compilation_context = compilation_context @compiled_content_store = compiled_content_store end |
Instance Attribute Details
#compilation_context ⇒ Object (readonly)
Returns the value of attribute compilation_context.
11 12 13 |
# File 'lib/nanoc/core/view_context_for_compilation.rb', line 11 def compilation_context @compilation_context end |
#compiled_content_store ⇒ Object (readonly)
Returns the value of attribute compiled_content_store.
12 13 14 |
# File 'lib/nanoc/core/view_context_for_compilation.rb', line 12 def compiled_content_store @compiled_content_store end |
#dependency_tracker ⇒ Object (readonly)
Returns the value of attribute dependency_tracker.
10 11 12 |
# File 'lib/nanoc/core/view_context_for_compilation.rb', line 10 def dependency_tracker @dependency_tracker end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
9 10 11 |
# File 'lib/nanoc/core/view_context_for_compilation.rb', line 9 def items @items end |
#reps ⇒ Object (readonly)
Returns the value of attribute reps.
8 9 10 |
# File 'lib/nanoc/core/view_context_for_compilation.rb', line 8 def reps @reps end |
Instance Method Details
#assigns_for(rep, site:) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/nanoc/core/view_context_for_compilation.rb', line 30 def assigns_for(rep, site:) last_content = @compiled_content_store.get_current(rep) content_or_filename_assigns = if last_content.binary? { filename: last_content.filename } else { content: last_content.string } end content_or_filename_assigns.merge( item: Nanoc::Core::CompilationItemView.new(rep.item, self), rep: Nanoc::Core::CompilationItemRepView.new(rep, self), item_rep: Nanoc::Core::CompilationItemRepView.new(rep, self), items: Nanoc::Core::ItemCollectionWithRepsView.new(site.items, self), layouts: Nanoc::Core::LayoutCollectionView.new(site.layouts, self), config: Nanoc::Core::ConfigView.new(site.config, self), ) end |