Class: Hobby::Pages::Directory::Page
- Inherits:
-
Object
- Object
- Hobby::Pages::Directory::Page
- Defined in:
- lib/hobby/pages.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(path, directory) ⇒ Page
constructor
A new instance of Page.
- #render(app) ⇒ Object
Constructor Details
#initialize(path, directory) ⇒ Page
Returns a new instance of Page.
128 129 130 131 132 133 134 135 136 |
# File 'lib/hobby/pages.rb', line 128 def initialize path, directory @layout = directory.default_layout @name = File.basename path, '.slim' @template = Tilt.new path script_file = "#{directory.to_s}/html/ruby/#{name}.rb" @script = IO.read script_file if File.exist? script_file end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
126 127 128 |
# File 'lib/hobby/pages.rb', line 126 def name @name end |
Instance Method Details
#render(app) ⇒ Object
138 139 140 141 142 143 144 |
# File 'lib/hobby/pages.rb', line 138 def render app app.instance_eval @script if @script @layout.render app do @template.render app end end |