lib/view.rb in inqlude-0.0.3 vs lib/view.rb in inqlude-0.0.4

- old
+ new

@@ -26,17 +26,15 @@ assert_dir output_dir assert_dir "#{output_dir}/public" system "cp #{view_dir}/public/* #{output_dir}/public/" - index = template "index" - engine = Haml::Engine.new index + render_template "index", output_dir + render_template "about", output_dir + render_template "get", output_dir + render_template "contribute", output_dir - File.open "#{output_dir}/index.html", "w" do |file| - file.puts engine.render( binding ) - end - library_path = "#{output_dir}/libraries/" assert_dir library_path engine = Haml::Engine.new template "library" @@ -44,11 +42,19 @@ File.open library_path + manifest["name"] + ".html", "w" do |file| @manifest = manifest file.puts engine.render( binding ) end end + end + def render_template name, output_dir + page = template name + engine = Haml::Engine.new page + + File.open "#{output_dir}/#{name}.html", "w" do |file| + file.puts engine.render( binding ) + end end def m attr @manifest[ attr ] end @@ -57,9 +63,16 @@ "<a href=\"libraries/#{name}.html\">#{name}</a>" end def link url "<a href=\"#{url}\" target=\"_blank\">#{url}</a>" + end + + def link_to title, url + if url !~ /^mailto:/ && url !~ /^http:/ + url += ".html" + end + "<a href=\"#{url}\">#{title}</a>" end def manifests if @manifest_handler.manifests.empty? @manifest_handler.read_remote