tweaks and erb

This commit is contained in:
tdreyno 2010-04-28 14:26:20 -07:00
parent 25ce57017b
commit 071e65b921
5 changed files with 30 additions and 2 deletions

View file

@ -12,7 +12,9 @@ module Middleman
end
autoload :Base, "middleman/base"
autoload :ERb, "middleman/erb"
autoload :Haml, "middleman/haml"
autoload :Sass, "middleman/sass"
autoload :Helpers, "middleman/helpers"
end

View file

@ -126,6 +126,7 @@ module Middleman
end
end
require "middleman/erb"
# Haml is required & includes helpers
require "middleman/haml"
require "middleman/sass"
@ -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

24
lib/middleman/erb.rb Executable file
View file

@ -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

View file

@ -13,7 +13,7 @@ module Middleman
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>"

View file

@ -9,7 +9,7 @@ rescue LoadError
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