Skip to content
Browse files

Switch the erb template usage to use the new TemplateVars

  • Loading branch information...
1 parent 7f0ca65 commit 46f5d84b2a8d26d490439f9181fc8a2681054b7b @copiousfreetime committed Jul 7, 2013
Showing with 11 additions and 8 deletions.
  1. +6 −4 lib/heel/directory_indexer.rb
  2. +5 −4 lib/heel/error_response.rb
View
10 lib/heel/directory_indexer.rb
@@ -56,8 +56,7 @@ def reload_template
#
def index_page_for(req)
reload_template if reload_on_template_change?
- dir = req.request_path
- base_uri = req.path_info
+ dir = req.request_path
entries = []
Dir.entries(dir).each do |entry|
next if should_ignore?(entry)
@@ -88,8 +87,11 @@ def index_page_for(req)
entries << entry_data
end
- entries = entries.sort_by { |e| e.link }
- return template.result(binding)
+ template_vars = TemplateVars.new( :base_uri => req.path_info )
+ template_vars.entries = entries.sort_by { |e| e.link }
+ template_vars.homepage = Heel::Configuration::HOMEPAGE
+
+ return template.result( template_vars.binding_for_template )
end
# essentially this is strfbytes from facets
View
9 lib/heel/error_response.rb
@@ -33,10 +33,11 @@ def initialize(base_uri, body, status = 404, header = {})
end
def finish
- status = @response.status # for the template
- message = ::Rack::Utils::HTTP_STATUS_CODES[status] # for the template
- homepage = ErrorResponse.homepage # for the template
- content = ErrorResponse.template.result( binding )
+ template_vars = TemplateVars.new( :status => @response.status,
+ :message => Rack::Utils::HTTP_STATUS_CODES[@response.status],
+ :homepage => ErrorResponse.homepage )
+
+ content = ErrorResponse.template.result( template_vars.binding_for_template )
@response.write( content )
return @response.finish
end

0 comments on commit 46f5d84

Please sign in to comment.
Something went wrong with that request. Please try again.