Class: PageSnippet

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/page_snippet.rb

Instance Method Summary collapse

Instance Method Details

#to_sObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/models/page_snippet.rb', line 10

def to_s
  if content
    case filter
      when "none"
        content.html_safe
      when "textile"
        RedCloth.new(content).to_html.html_safe
      when "markdown"
        BlueCloth.new(content).to_html.html_safe
      when "erb"
        require "erb"
        eval(ERB.new(content).src).html_safe
      when "erb+textile"
        require "erb"
        textilize eval(ERB.new(content).src).html_safe
      when "html"
        content.html_safe
    end      
  end
end