Sha256: e09899fb4091e24bae8edb2f9da5e013c8587bd28295ac5023c265c5eef3bab7

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.2"

      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.2 lib/administrate/field/markdown.rb