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 = "      <!DOCTYPE HTML>\n      <html lang=\"en\">\n      <head>\n          <meta charset=\"UTF-8\">\n          <title>\#{name}</title>\n      </head>\n      <body>\n          <div class=\"info\">\n              \#{body}\n          </div>\n      </body>\n      </html>\n    HTML\n    i.write(html)\n  end\nend\n"