Class: Glue::Template::Helper

Inherits:
Object
  • Object
show all
Defined in:
lib/glue/template/helper.rb

Instance Method Summary collapse

Instance Method Details

#haml(text) ⇒ Object



12
13
14
# File 'lib/glue/template/helper.rb', line 12

def haml(text)
  Haml::Engine.new(text).to_html(self)
end

#markdown(text) ⇒ Object



4
5
6
# File 'lib/glue/template/helper.rb', line 4

def markdown(text)
  RDiscount.new(text).to_html
end

#render(path) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/glue/template/helper.rb', line 16

def render(path)
  parts = [GLUE_ROOT, "views", File.dirname(path), "_" + File.basename(path)]
  parts.reject! {|p| p == "." }
  
  path = File.join(*parts)
  
  if File.exists?(file = "#{path}.haml")
    haml File.read(file)
  elsif File.exists?(file = "#{path}.markdown")
    markdown File.read(file)
  elsif File.exists?(file = "#{path}.textile")
    textile File.read(file)
  else
    "Missing partial at <strong>#{path}</strong>"
  end
end

#textile(text) ⇒ Object



8
9
10
# File 'lib/glue/template/helper.rb', line 8

def textile(text)
  RedCloth.new(text).to_html
end