Class: Vintage::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/vintage/renderer.rb

Overview

Core rendering class.

Class Method Summary collapse

Class Method Details

.erb(template, request) ⇒ Object

Render an ERb template. Uses Erubis if available and if not, falls back to standard ERb.



14
15
16
17
18
19
20
# File 'lib/vintage/renderer.rb', line 14

def self.erb(template, request)
  if Erubis
    Erubis::Eruby.new(template).evaluate(request)
  else
    ERB.new(template).result(request.send(:binding))
  end
end

.haml(template, request) ⇒ Object

Render a HAML template.



23
24
25
26
27
28
29
# File 'lib/vintage/renderer.rb', line 23

def self.haml(template, request)
  if Haml
    Haml::Engine.new(template).render(request)
  else
    raise "You don't have Haml installed!"
  end
end

.mab(template, request) ⇒ Object

Render a Markaby template.



53
54
55
56
57
58
59
# File 'lib/vintage/renderer.rb', line 53

def self.mab(template, request)
  if Markaby
    Markaby::Builder.new.instance_eval(template).to_s
  else
    raise "You don't have Markaby installed!"
  end
end

.markdown(template, request) ⇒ Object

Render a Markdown template using BlueCloth, or if that isn’t available, using RedCloth.



42
43
44
45
46
47
48
49
50
# File 'lib/vintage/renderer.rb', line 42

def self.markdown(template, request)
  if BlueCloth
    BlueCloth.new(template).to_html
  elsif RedCloth
    RedCloth.new(template).to_html
  else
    raise "You don't have BlueCloth or RedCloth installed!"
  end
end

.textile(template, request) ⇒ Object

Render a Textile template using RedCloth.



32
33
34
35
36
37
38
# File 'lib/vintage/renderer.rb', line 32

def self.textile(template, request)
  if RedCloth
    RedCloth.new(template).to_html
  else
    raise "You don't have RedCloth installed!"
  end
end