Method: BookLab::SML::Rules::File.to_html

Defined in:
lib/booklab/sml/rules/file.rb

.to_html(node, opts = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/booklab/sml/rules/file.rb', line 13

def self.to_html(node, opts = {})
  attrs = attributes(node)
  attrs[:name] ||= ""

  return attrs[:name] if attrs[:src].blank?

  humanize_size = number_to_human_size(attrs[:size] || 0)

  out = "  <a class=\"attachment-file\" title=\"\#{attrs[:name]}\" target=\"_blank\" href=\"\#{attrs[:src]}\">\n    <span class=\"icon-box\"><i class=\"fas fa-file\"></i></span>\n    <span class=\"filename\">\#{escape_html(attrs[:name])}</span>\n    <span class=\"filesize\">\#{escape_html(humanize_size)}</span>\n  </a>\n  HTML\n\n  out\nend\n"