Class: LB::Project::Render

Inherits:
Object
  • Object
show all
Defined in:
lib/lb/project/render.rb

Overview

Render

Instance Method Summary collapse

Instance Method Details

#callObject



7
8
9
10
11
12
# File 'lib/lb/project/render.rb', line 7

def call
  Page.page_registry.each do |name, klass|
    page = klass.new
    File.write(file_for(name), page.call(options(page)))
  end
end

#file_for(name) ⇒ Object



14
15
16
17
18
# File 'lib/lb/project/render.rb', line 14

def file_for(name)
  File.expand_path("#{name}.html", LB::Project.public_path).tap do |file|
    FileUtils.mkdir_p File.dirname(file)
  end
end

#options(page, locals = {}) ⇒ Object



20
21
22
23
24
25
# File 'lib/lb/project/render.rb', line 20

def options(page, locals = {})
  {
    context: ::Struct.new(:site, :page).new(LB::Project::Site.new, page),
    locals: locals
  }
end