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.

Methods

included   method_missing   new   render   renderer  

Included Modules

Waves::ResponseMixin

Attributes

request  [R] 

Public Class methods

[Source]

    # 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

[Source]

    # File lib/views/mixin.rb, line 38
38:       def  initializeinitialize( request ) ; @request = request ; @layout = :default ; end

Public Instance methods

Render the template with the name of the missing method.

[Source]

    # 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>

[Source]

    # 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

Return the first renderer for which a template file can be found. Uses Renderers::Mixin.filename to construct the filename for each renderer.

[Source]

    # File lib/views/mixin.rb, line 42
42:       def renderer(path) ; Views.renderer_for( :templates / path) ; end

[Validate]