Sha256: 348677d6c3cdc2ed059be9233f4815371f85dbb06e40ca5a0fb7e7aabae0ca28
Contents?: true
Size: 1008 Bytes
Versions: 18
Compression:
Stored size: 1008 Bytes
Contents
require 'redcarpet' module PushType class MarkdownField < PushType::FieldType options form_helper: :text_area, renderer: Redcarpet::Render::HTML, render_options: {}, extensions: { autolink: true, fenced_code_blocks: true, no_intra_emphasis: true, space_after_headers: true, strikethrough: true, tables: true, underline: true } def compiled_value markdown.render value unless value.nil? end private def markdown @markdown ||= Redcarpet::Markdown.new(renderer, @opts[:extensions]) end def renderer @opts[:renderer].new @opts[:render_options] end on_instance do |object, field| object.presenter_class.class_eval do define_method(field.name) { field.compiled_value } unless method_defined?(field.name) end end end end
Version data entries
18 entries across 18 versions & 1 rubygems