Skip to content

Commit

Permalink
tweaks and erb
Browse files Browse the repository at this point in the history
  • Loading branch information
tdreyno committed Apr 28, 2010
1 parent 25ce570 commit 071e65b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/middleman.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ module Rack
end

autoload :Base, "middleman/base"
autoload :ERb, "middleman/erb"
autoload :Haml, "middleman/haml"
autoload :Sass, "middleman/sass"
autoload :Helpers, "middleman/helpers"

end
2 changes: 2 additions & 0 deletions lib/middleman/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def process_request(layout = :layout)
end
end

require "middleman/erb"
# Haml is required & includes helpers
require "middleman/haml"
require "middleman/sass"
Expand All @@ -144,6 +145,7 @@ class Middleman::Base
disable :automatic_image_sizes
disable :relative_assets
disable :cache_buster
disable :ugly_haml

# Default build features
configure :build do
Expand Down
24 changes: 24 additions & 0 deletions lib/middleman/erb.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require "erb"

module Middleman
module ERb
module Renderer
def self.included(base)
base.supported_formats << "erb"
end

def render_path(path, layout)
if template_exists?(path, :erb)
layout = false if File.extname(path) == ".xml"
erb(path.to_sym, :layout => layout)
else
super
end
end
end
end
end

class Middleman::Base
include Middleman::ERb::Renderer
end
2 changes: 1 addition & 1 deletion lib/middleman/haml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def render_path(path, layout)
result = nil
begin
layout = false if File.extname(path) == ".xml"
result = haml(path.to_sym, :layout => layout)
result = haml(path.to_sym, :layout => layout, :ugly => Middleman::Base.enabled?(:ugly_haml))
rescue ::Haml::Error => e
result = "Haml Error: #{e}"
result << "<pre>Backtrace: #{e.backtrace.join("\n")}</pre>"
Expand Down
2 changes: 1 addition & 1 deletion lib/middleman/sass.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
puts "YUI-Compressor not available. Install it with: gem install yui-compressor"
end

module Middleman::Sass
module Middleman::Sass
def self.included(base)
base.supported_formats << "sass"
end
Expand Down

0 comments on commit 071e65b

Please sign in to comment.