Module: Templette::DataAccessors

Includes:
Helpers
Included in:
MethodCollector, Page, Page::Section
Defined in:
lib/templette/data_accessors.rb

Instance Method Summary collapse

Methods included from Helpers

#image_tag, #script_tag, #stylesheet_tag

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(symbol) ⇒ Object

:nodoc:

Raises:



17
18
19
# File 'lib/templette/data_accessors.rb', line 17

def method_missing(symbol) # :nodoc:
  raise PageError.new(page, "No method '#{symbol}' defined in the yaml")
end

Instance Method Details

#attributesObject

:nodoc:



5
6
7
# File 'lib/templette/data_accessors.rb', line 5

def attributes # :nodoc:
  @attributes ||= {}
end

#generate_accessors(accessors = {}) ⇒ Object

:nodoc:



9
10
11
# File 'lib/templette/data_accessors.rb', line 9

def generate_accessors(accessors = {}) # :nodoc:
  accessors.each_pair { |k,v| generate_accessor(k, v) }
end

#include_helpers(helpers) ⇒ Object

:nodoc:



13
14
15
# File 'lib/templette/data_accessors.rb', line 13

def include_helpers(helpers) # :nodoc:
  helpers.each { |helper| add_helper(helper) }
end

#partial(filename) ⇒ Object

:nodoc:



21
22
23
24
25
26
# File 'lib/templette/data_accessors.rb', line 21

def partial(filename) # :nodoc:
  raise PageError.new(page, "Rendering #{partial_path(filename)} failed.  File not found.") unless File.exists?(partial_path(filename))
  Engineer.engine_for(Engineer.determine_type(filename)).render(File.read(partial_path(filename)), page._binding)
rescue RenderError => e
  raise PageError.new(page, e.message)      
end