Sha256: e1ec8a13733abd01f558f32a59fd57e44be09595c5b9b9864ca2a8666bf87e45

Contents?: true

Size: 479 Bytes

Versions: 1

Compression:

Stored size: 479 Bytes

Contents

require "administrate/field/base"
require "rails"
require "kramdown"

module Administrate
  module Field
    class Markdown < Administrate::Field::Base
      VERSION = "0.0.1"

      class Engine < ::Rails::Engine
      end

      def rendered
        Kramdown::Document.new(data).to_html
      end

      def truncate
        data.to_s[0...truncation_length]
      end

      private

      def truncation_length
        options.fetch(:truncate, 50)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
administrate-field-markdown-0.0.1 lib/administrate/field/markdown.rb