Method: Moka::Compiler#compile!

Defined in:
lib/commands/lib/compiler.rb

#compile!(group, page_name, manifest = nil) ⇒ Object

Compile page creating its file in the compiled dir



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/commands/lib/compiler.rb', line 8

def compile!(group, page_name, manifest = nil)
  if manifest.nil?
    manifest = YAML.load_file(File.expand_path("manifest.yml", MOKA_ROOT))
  end

  puts "compiling #{group}:#{page_name}..."

  page_string = compile(group, page_name, manifest)
  path = manifest["site"][group][page_name]["path"]

  page_dir = File.dirname(path)
  unless page_dir == "."
    FileUtils.mkdir_p(File.expand_path("compiled/"+page_dir, MOKA_ROOT))
  end
  compiled_file = File.new(File.expand_path("compiled/"+path, MOKA_ROOT), "w")
  compiled_file.print(page_string)
  compiled_file.close
end