Sha256: 92d1262a46e10e8894baabf37ee0a640e2b6c38103f691b74cac6e5c2cab73b1

Contents?: true

Size: 715 Bytes

Versions: 13

Compression:

Stored size: 715 Bytes

Contents

module Smithy
  class Content < ActiveRecord::Base
    include Smithy::ContentBlocks::Model

    validates_presence_of :content

    before_save :render_markdown_content

    class << self
      def content_block_description
        "Content is primarily used for adding text-based content to your pages"
      end
    end

    def formatted_content
      self.markdown_content
    end

    def to_liquid
      {
        'id' => self.id,
        'content' => self.content,
        'formatted_content' => self.formatted_content
      }
    end

    private
      def render_markdown_content
        formatter = Smithy::Formatter.new(self.content)
        self.markdown_content = formatter.render
      end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
smithycms-0.5.99 app/models/smithy/content.rb
smithycms-0.6.2 app/models/smithy/content.rb
smithycms-0.6.1 app/models/smithy/content.rb
smithycms-0.5.2 app/models/smithy/content.rb
smithycms-0.6.0 app/models/smithy/content.rb
smithycms-0.5.1 app/models/smithy/content.rb
smithycms-0.5.0 app/models/smithy/content.rb
smithycms-0.4.5 app/models/smithy/content.rb
smithycms-0.4.4 app/models/smithy/content.rb
smithycms-0.4.3 app/models/smithy/content.rb
smithycms-0.4.2 app/models/smithy/content.rb
smithycms-0.4.1 app/models/smithy/content.rb
smithycms-0.4.0 app/models/smithy/content.rb