mirror of
https://github.com/danbee/danbarberphoto
synced 2025-03-04 08:49:07 +00:00
Add truncate method
This commit is contained in:
parent
1f35c7210e
commit
81a2150cc1
@ -5,11 +5,19 @@ module Administrate
|
||||
renderer.render(data).html_safe
|
||||
end
|
||||
|
||||
def truncate
|
||||
data.to_s[0...truncation_length]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def renderer
|
||||
Redcarpet::Markdown.new(Redcarpet::Render::HTML, extensions: {})
|
||||
end
|
||||
|
||||
def truncation_length
|
||||
options.fetch(:truncate, 50)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user