Class: Genit::PageCompiler
- Inherits:
-
Object
- Object
- Genit::PageCompiler
- Defined in:
- lib/genit/project/page_compiler.rb
Overview
Compile a single page.
Instance Method Summary collapse
-
#compile ⇒ Object
Public: Compile the page.
-
#initialize(working_dir, filename) ⇒ PageCompiler
constructor
Public: Constructor.
Constructor Details
#initialize(working_dir, filename) ⇒ PageCompiler
Public: Constructor.
working_dir - The String working directory, where live the project. filename - The String name of the page
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/genit/project/page_compiler.rb', line 12 def initialize working_dir, filename @working_dir = working_dir @filename = filename # file = File.join(@working_dir, 'src/templates/main.html') # @template = XmlDocument.open(file) file = File.join(@working_dir, 'src/templates/main') if File.exists?("#{file}.html") file = file + ".html" @template = XmlDocument.open(file) elsif File.exists?("#{file}.haml") file = file + ".haml" @template = XmlDocument.open_via_haml(file) else error "No template found" end end |
Instance Method Details
#compile ⇒ Object
Public: Compile the page.
Returns a Nokogiri::XML document.
32 33 34 35 36 37 38 |
# File 'lib/genit/project/page_compiler.rb', line 32 def compile compile_body compile_head builder = ScriptBuilder.new @template builder.build_for_page @filename end |