class HTML

Public Class Methods

new(str) click to toggle source
# File lib/zarchitect/html.rb, line 3
def initialize(str)
  @data = Hash.new
  @meta = Hash.new
  @path = str
end

Public Instance Methods

compose() click to toggle source
# File lib/zarchitect/html.rb, line 22
def compose
  set_view
  @data["view"] = @view.output
  @data["meta"] = @meta
  set_layout
end
output() click to toggle source
# File lib/zarchitect/html.rb, line 34
def output
  @layout.output
end
set_data(key, value) click to toggle source
# File lib/zarchitect/html.rb, line 9
def set_data(key, value)
  @data[key] = value
end
set_meta(key, value) click to toggle source
# File lib/zarchitect/html.rb, line 13
def set_meta(key, value)
  @meta[key] = value
end
set_templates(layout, view) click to toggle source
# File lib/zarchitect/html.rb, line 17
def set_templates(layout, view)
  @layout_path = layout
  @view_path = view
end
write() click to toggle source
# File lib/zarchitect/html.rb, line 29
def write
  GPI.print "Writing HTML to #{@path}.", GPI::CLU.check_option('v')
  File.open(@path, "w") { |f| f.write(@layout.output) }
end

Private Instance Methods

set_layout() click to toggle source
# File lib/zarchitect/html.rb, line 40
def set_layout
  @layout = ZERB.new(@layout_path)
  @layout.handle_data(@data)
  @layout.prepare
  @layout.render
end
set_view() click to toggle source
# File lib/zarchitect/html.rb, line 47
def set_view
  @view = ZERB.new(@view_path)
  @view.handle_data(@data)
  @view.prepare
  @view.render
end