Class: Mack::Rendering::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/rendering/base.rb

Overview

This is the base class from which all rendering systems need to extend.

Example:

class Mack::Rendering::Pdf < Mack::Rendering::Base
  def render
    # do work to render stuff as a PDF
  end
end

Now add this to the list of available render systems:

app_config.mack.rendering_systems << :pdf

You should now be able to do this in your controller:

class MyAwesomeController < Mack::Controller::Base
  def pdf
    render(:pdf => "my_pdf_template")
  end
end

Direct Known Subclasses

Action, Partial, Public, Text, Url, Xml

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view_binder, options) ⇒ Base

Returns a new instance of Base.



27
28
29
30
# File 'lib/rendering/base.rb', line 27

def initialize(view_binder, options)
  self.view_binder = view_binder
  self.options = {:parameters => {}}.merge(options)
end

Instance Attribute Details

#optionsObject

The options associated with this render call



25
26
27
# File 'lib/rendering/base.rb', line 25

def options
  @options
end

#view_binderObject

The Mack::ViewBinder that called this rendering system.



24
25
26
# File 'lib/rendering/base.rb', line 24

def view_binder
  @view_binder
end

Instance Method Details

#params(key) ⇒ Object

Maps to the view_binder’s param method. See also Mack::ViewBinder params.



37
38
39
# File 'lib/rendering/base.rb', line 37

def params(key)
  self.view_binder.params(key)
end