Class: Frozen::Template::View

Inherits:
Base
  • Object
show all
Defined in:
lib/frozen/template/view.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#file_path, #template_root_path

Instance Method Summary collapse

Methods inherited from Base

#build_file_path, #build_filename, #file_type, #read_from_file, #relative_path, #relative_to_root, #render_to_file, #template_filename, #template_path

Constructor Details

#initialize(options = {}) ⇒ View

Returns a new instance of View.



11
12
# File 'lib/frozen/template/view.rb', line 11

def initialize(options={})
end

Instance Attribute Details

#layout_pathObject

Returns the value of attribute layout_path.



9
10
11
# File 'lib/frozen/template/view.rb', line 9

def layout_path
  @layout_path
end

#optionsObject

Returns the value of attribute options.



8
9
10
# File 'lib/frozen/template/view.rb', line 8

def options
  @options
end

Instance Method Details

#build_extensionObject



18
19
20
# File 'lib/frozen/template/view.rb', line 18

def build_extension
  ".html"
end

#build_pathObject



22
23
24
# File 'lib/frozen/template/view.rb', line 22

def build_path
  ""
end

#contentsObject



14
15
16
# File 'lib/frozen/template/view.rb', line 14

def contents
  read_from_file(file_path)
end

#get_layout_pathObject



31
32
33
# File 'lib/frozen/template/view.rb', line 31

def get_layout_path
  File.join(layout_path, "default.html.slim")
end

#layoutObject



35
36
37
# File 'lib/frozen/template/view.rb', line 35

def layout
  Slim::Template.new {File.read(get_layout_path)}
end

#renderObject



26
27
28
29
# File 'lib/frozen/template/view.rb', line 26

def render
  env = Frozen::Environment::Base.new(self)
  layout.render(env) { Slim::Template.new { contents }.render(env) }
end