Sha256: 0f7e2cde8f9e33eec64bdbcf9315d686428e85ff0f8e2bba78f29d0d08192dfd

Contents?: true

Size: 715 Bytes

Versions: 5

Compression:

Stored size: 715 Bytes

Contents

class PageSnippet < ActiveRecord::Base
  # Validations
  validates :name, :presence => true, :uniqueness => true
  
  # Relationships
  if PageEngine.class_exists?('Asset')
    has_assets
  end

  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
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
page_engine-0.0.5 app/models/page_snippet.rb
page_engine-0.0.4 app/models/page_snippet.rb
page_engine-0.0.3 app/models/page_snippet.rb
page_engine-0.0.2 app/models/page_snippet.rb
page_engine-0.0.1 app/models/page_snippet.rb