lib/server.rb in rubrowser-0.1.3 vs lib/server.rb in rubrowser-0.1.4

- old
+ new

@@ -1,12 +1,14 @@ require 'webrick' -require 'haml' require 'data' require 'json' +require 'erb' module Rubrowser class Server < WEBrick::HTTPServer + include ERB::Util + def self.start(paths) new(paths).start end def initialize(paths) @@ -26,16 +28,11 @@ attr_reader :data def root(path) return file(path) if file?(path) - - haml :index, - locals: { - constants: data.constants, - occurences: data.occurences - } + erb :index end def file?(path) path = resolve_file_path("/public#{path}") File.file?(path) @@ -43,14 +40,13 @@ def file(path) File.read(resolve_file_path("/public#{path}")) end - def haml(template, options = {}) - path = resolve_file_path("/views/#{template}.haml") + def erb(template) + path = resolve_file_path("/views/#{template}.erb") file = File.open(path).read - locals = options.delete(:locals) || {} - Haml::Engine.new(file, options).render(self, locals) + ERB.new(file).result binding end def resolve_file_path(path) File.expand_path("../..#{path}", __FILE__) end