Class: Administrate::Field::SimpleMarkdown

Inherits:
Text
  • Object
show all
Defined in:
lib/administrate/field/simple_markdown.rb

Defined Under Namespace

Classes: Engine

Instance Method Summary collapse

Instance Method Details

#dataObject



15
16
17
# File 'lib/administrate/field/simple_markdown.rb', line 15

def data
  @data || ''
end

#easymde_optionsObject



19
20
21
22
23
# File 'lib/administrate/field/simple_markdown.rb', line 19

def easymde_options
  options.fetch(:easymde_options, {})
    .transform_keys { |key| key.to_s.camelize(:lower) }
    .to_json
end

#html_idObject



33
34
35
36
37
38
# File 'lib/administrate/field/simple_markdown.rb', line 33

def html_id
  [
    resource.class.name.underscore.gsub('/', '_'),
    attribute
  ].join('_')
end

#to_htmlObject



25
26
27
# File 'lib/administrate/field/simple_markdown.rb', line 25

def to_html
  markdown(html_renderer).render(data).html_safe
end

#to_sObject



29
30
31
# File 'lib/administrate/field/simple_markdown.rb', line 29

def to_s
  markdown(plaintext_renderer).render(data)
end