Module: Stratify::Renderable

Included in:
Activity
Defined in:
lib/stratify/renderable.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
# File 'lib/stratify/renderable.rb', line 5

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#presenterObject

Returns the object that will be passed to the template for rendering.

The default implementation returns ‘self’ (i.e., the renderable object).

Subclasses may optionally override this method to provide an object better suited for use in rendering (e.g., an object implementing the presenter pattern).



37
38
39
# File 'lib/stratify/renderable.rb', line 37

def presenter
  self
end

#to_htmlObject



25
26
27
28
# File 'lib/stratify/renderable.rb', line 25

def to_html
  template_handler = Tilt[self.class.template_format].new { self.class.template.strip }
  template_handler.render(presenter)
end