Module: Waves::Views

Defined in:
lib/views/mixin.rb,
lib/views/errors.rb

Defined Under Namespace

Modules: Mixin Classes: Base, Errors, NoTemplateError

Class Method Summary collapse

Class Method Details

.render(path, assigns = {}) ⇒ Object

Raises:



15
16
17
18
19
# File 'lib/views/mixin.rb', line 15

def self.render( path, assigns = {} )
  template = Views.renderer_for(path) 
  raise NoTemplateError.new( path ) if template.nil?
  template.render( path, assigns )
end

.renderer_for(path) ⇒ Object



9
10
11
12
13
# File 'lib/views/mixin.rb', line 9

def self.renderer_for(path)
  @renderers.find do |renderer|
    File.extname( path ) == ".#{renderer::Extension}" or File.exists?( renderer.filename( path ) )
  end
end

.renderersObject

A class method that returns the known Renderers, which is any module that is defined within Waves::Renderers and includes the Renderers::Mixin. You can define new Renderers simply be reopening Waves::Renderers and defining a module that mixes in Renderers::Mixin.



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

def self.renderers ; @renderers ||= [] ; end