| Module | Waves::Views::Mixin |
| In: |
lib/views/mixin.rb
|
The View mixin simply sets up the machinery for invoking a template, along with methods for accessing the request assigns and the standard interface for invoking a view method.
| request | [R] |
# File lib/views/mixin.rb, line 32
32: def self.included( target )
33: def target.process( request, *args, &block )
34: self.new( request ).instance_exec( *args, &block )
35: end
36: end
# File lib/views/mixin.rb, line 38
38: def initializeinitialize( request ) ; @request = request ; @layout = :default ; end
Render the template with the name of the missing method.
# File lib/views/mixin.rb, line 53
53: def method_missing(name,*args) ; render( name, *args ) ; end
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>
# File lib/views/mixin.rb, line 46
46: def render( path, assigns = {} )
47: qpath = "#{self.class.basename.snake_case}/#{path}"
48: Waves.log.debug "Rendering template: #{qpath}"
49: Views.render( :templates / qpath, assigns.merge!( :request => request ))
50: end