diff --git a/lib/middleman.rb b/lib/middleman.rb index cf8e9bee..c2713a93 100644 --- a/lib/middleman.rb +++ b/lib/middleman.rb @@ -82,16 +82,14 @@ class Middleman < Sinatra::Base get /(.*)/ do |path| path << "index.html" if path.match(%r{/$}) path.gsub!(%r{^/}, '') - - @template = path.gsub(File.extname(path), '').to_sym - @full_request_path = path + path.gsub!(File.extname(path), '') result = nil begin %w(haml erb builder maruku mab).detect do |renderer| - next false if !File.exists?(File.join(options.views, "#{@template}.#{renderer}")) + next false if !File.exists?(File.join(options.views, "#{path}.#{renderer}")) renderer = "markaby" if renderer == "mab" - result = send(renderer.to_sym, @template) + result = send(renderer.to_sym, path.to_sym) end rescue Haml::Error => e result = "Haml Error: #{e}" diff --git a/lib/middleman/helpers.rb b/lib/middleman/helpers.rb index 34b4c602..9d7b3ae6 100644 --- a/lib/middleman/helpers.rb +++ b/lib/middleman/helpers.rb @@ -5,8 +5,12 @@ def link_to(title, url="#", params={}) end def page_classes(*additional) + path = env["REQUEST_PATH"] + path << "index.html" if path.match(%r{/$}) + path.gsub!(%r{^/}, '') + classes = [] - parts = @full_request_path.split('.')[0].split('/') + parts = path.split('.')[0].split('/') parts.each_with_index { |path, i| classes << parts.first(i+1).join('_') } classes << "index" if classes.empty?