Class: Page

Inherits:
Object
  • Object
show all
Defined in:
lib/d_to_html.rb

Class Method Summary collapse

Class Method Details

.save(body, name: 'index.html', bypass_html: false) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/d_to_html.rb', line 4

def self.save(body, name: 'index.html', bypass_html: false)
  body = Sanitize.fragment(body) unless bypass_html
  File.open(name, "w+") do |i|
    html = <<~HTML
      <!DOCTYPE HTML>
      <html lang="en">
      <head>
          <meta charset="UTF-8">
          <title>#{name}</title>
      </head>
      <body>
          <div class="info">
              #{body}
          </div>
      </body>
      </html>
    HTML
    i.write(html)
  end
end