Class: Brite::Part

Inherits:
Model
  • Object
show all
Defined in:
lib/brite/part.rb

Overview

In you templates:

<%= part.some_part_name %>

Defined Under Namespace

Classes: Manager

Instance Attribute Summary

Attributes inherited from Model

#file, #site

Instance Method Summary collapse

Methods inherited from Model

#[], #[]=, #config, #method_missing, #part, #rendering_fields, #to_binding, #to_h, #update

Constructor Details

#initialize(site, file, copy = {}) ⇒ Part

New Page.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/brite/part.rb', line 10

def initialize(site, file, copy={})
  @site = site
  @file = file

  initialize_defaults

  update(copy)

  @_template = Neapolitan.file(file, :stencil=>site.config.stencil) #site.page_defaults)

  update(@_template.)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Brite::Model

Instance Method Details

#basenameObject



38
39
40
# File 'lib/brite/part.rb', line 38

def basename
  @basename ||= File.basename(name)
end

#initialize_defaultsObject



24
25
26
27
28
29
30
# File 'lib/brite/part.rb', line 24

def initialize_defaults
  @layout = nil

  @part = nil 
  @name = nil
  @basename = nil
end

#nameObject



33
34
35
# File 'lib/brite/part.rb', line 33

def name
  @name ||= file.chomp('.part')
end

#renderObject

Render page or post template.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/brite/part.rb', line 44

def render
  render = @_template.render(self) #, &body)

  result = render.to_s

  if layout
    if layout_object = site.lookup_layout(layout)
      result = layout_object.render(self){ result }
    #else
    #  raise "No such layout -- #{layout}"
    end
  end

  result.to_s.strip
end