1
0
mirror of https://github.com/danbee/danbarberphoto synced 2025-03-04 08:49:07 +00:00
danbarberphoto/app/fields/markdown_field.rb
2016-04-20 12:13:31 +01:00

22 lines
320 B
Ruby

require "administrate/field/base"
class MarkdownField < Administrate::Field::Base
def to_s
data
end
def rendered
Kramdown::Document.new(data).to_html.html_safe
end
def truncate
data.to_s[0...truncation_length]
end
private
def truncation_length
options.fetch(:truncate, 50)
end
end