Class: Mullet::HTML::Layout

Inherits:
Object
  • Object
show all
Defined in:
lib/mullet/html/layout.rb

Overview

Extracts content from an HTML page and renders it in a layout. The layout is a template given these variables:

title : content of the title element from the page body : content of the body element from the page

The body variable typically contains HTML markup, so the layout must use the ‘data-escape-xml=“false”` command to prevent markup characters being escaped when rendering the variable.

Instance Method Summary collapse

Constructor Details

#initialize(template) ⇒ Layout

Constructor

Parameters:

  • template (Template)

    layout using the template



23
24
25
# File 'lib/mullet/html/layout.rb', line 23

def initialize(template)
  @template = template
end

Instance Method Details

#execute(page_html, output) ⇒ Object

Renders page data in a layout.

Parameters:

  • page_html (String)

    content from this HTML page will be rendered in the layout

  • output (#<<)

    where to write rendered output



33
34
35
36
# File 'lib/mullet/html/layout.rb', line 33

def execute(page_html, output)
  page = parse_page(page_html)
  @template.execute(page, output)
end