Module: Spreadhead::Render::InstanceMethods

Defined in:
lib/spreadhead/render.rb

Instance Method Summary collapse

Instance Method Details

#spreadhead(page) ⇒ Object

Show the contents of the specified page to be used when rendering. The page parameter can be either a string (the page url) or a Page object.

Returns:

  • The page text as a string



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/spreadhead/render.rb', line 20

def spreadhead(page)
  return '' unless page
  page = ::Page.find_by_url!(page) if page.is_a? String

  case page.formatting
    when 'markdown'
      BlueCloth.new(page.text).to_html
    when 'textile'
      r = RedCloth.new(page.text)
      r.hard_breaks = false
      r.to_html
    else
      page.text
  end        
end