Class: HtmlGenerator
- Inherits:
-
Object
- Object
- HtmlGenerator
- Defined in:
- lib/generate_html.rb
Instance Method Summary collapse
Instance Method Details
#generate_html(content, bypass_html = true, file_name = 'index.html') ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/generate_html.rb', line 4 def generate_html(content, bypass_html = true, file_name = 'index.html') content = Sanitize.fragment(content) unless bypass_html html = <<-HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>#{ file_name }</title> </head> <body> #{ content } </body> HTML File.open(file_name, 'w+') do |f| f.write(html) end system("xdg-open #{Dir.pwd}/#{file_name}") end |