Sha256: 14e30b21b780807a8d0d65d47e1d9afd1e3efe9e1bfc5ed87bbaa548804e4602

Contents?: true

Size: 879 Bytes

Versions: 1

Compression:

Stored size: 879 Bytes

Contents

module Thesis
  class PageContent < ActiveRecord::Base
    self.table_name = "page_contents"

    belongs_to :page
    
    def render
      case self.content_type.to_sym
      when :html
        render_html
      when :text
        render_text
      else
        render_html
      end
    end
    
    protected
    
    def render_html
      h = "<div class='thesis-content thesis-content-html' data-thesis-content-id='#{self.id}'>" +
      "#{self.content}" + 
      "</div>"
      h.html_safe
    end
    
    def render_text
      h = "<span class='thesis-content thesis-content-text' data-thesis-content-id='#{self.id}'>" +
      "#{self.content}" +
      "</span>"
      h.html_safe
    end
    
    def render_image
      h = "<div class='thesis-content thesis-content-image'>" +
      "<img src='#{self.content}' />" +
      "</div>"
      h.html_safe
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
thesis-0.0.4 lib/thesis/models/page_content.rb