Module: Waves::Views::Mixin::Ext

Defined in:
lib/views/mixin.rb

Overview

The Views::Mixin::Ext includes functionality that may be incompatible with some template engines. It is included when the Mixin is included unless the target class is incompatible

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object

Render the template with the name of the missing method. E.g. App::Views::Gnome.new.stink would look for templates/gnome/stink



54
# File 'lib/views/mixin.rb', line 54

def method_missing(name,*args) ; render( name, *args ) ; end

Instance Method Details

#render(name, assigns = {}) ⇒ Object

Render the template found in the directory named after this view (snake cased, of course) E.g. App::Views::Gnome.new.render( “stink” ) would look for templates/gnome/stink.<ext>



45
46
47
48
49
50
# File 'lib/views/mixin.rb', line 45

def render( name, assigns={})
  file = template_file(name)
  ext = File.extname(file).slice(1..-1)
  Waves.log.debug "Rendering: #{file}"
  self.send( ext, File.read(file), assigns.merge!( :request => request ))
end