Class: Ottogen::Layout::Context
- Inherits:
-
Object
- Object
- Ottogen::Layout::Context
- Defined in:
- lib/ottogen/layout.rb
Constant Summary collapse
- INCLUDES_DIR =
'_includes'
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Instance Method Summary collapse
- #binding_for_erb ⇒ Object
-
#initialize(content:, site:, page:) ⇒ Context
constructor
A new instance of Context.
- #partial(name) ⇒ Object
Constructor Details
#initialize(content:, site:, page:) ⇒ Context
Returns a new instance of Context.
47 48 49 50 51 |
# File 'lib/ottogen/layout.rb', line 47 def initialize(content:, site:, page:) @content = content @site = site @page = page end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
45 46 47 |
# File 'lib/ottogen/layout.rb', line 45 def content @content end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
45 46 47 |
# File 'lib/ottogen/layout.rb', line 45 def page @page end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
45 46 47 |
# File 'lib/ottogen/layout.rb', line 45 def site @site end |
Instance Method Details
#binding_for_erb ⇒ Object
53 54 55 |
# File 'lib/ottogen/layout.rb', line 53 def binding_for_erb binding end |
#partial(name) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/ottogen/layout.rb', line 57 def partial(name) path = File.join(INCLUDES_DIR, name) raise Error, "include '#{name}' not found at #{path}" unless File.exist?(path) ERB.new(File.read(path), trim_mode: '-').result(binding_for_erb) end |