require "haml" module Middleman module Haml module Renderer def self.included(base) base.supported_formats << "haml" base.helpers Middleman::Haml::Helpers end def render_path(path) if template_exists?(path, :haml) result = nil begin result = haml(path.to_sym, :layout => File.extname(path) != ".xml") rescue ::Haml::Error => e result = "Haml Error: #{e}" result << "
Backtrace: #{e.backtrace.join("\n")}" end result else super end end end module Helpers def haml_partial(name, options = {}) item_name = name.to_sym counter_name = "#{name}_counter".to_sym if collection = options.delete(:collection) collection.enum_for(:each_with_index).collect do |item,index| haml_partial name, options.merge(:locals => {item_name => item, counter_name => index+1}) end.join elsif object = options.delete(:object) haml_partial name, options.merge(:locals => {item_name => object, counter_name => nil}) else haml "_#{name}".to_sym, options.merge(:layout => false) end end end module Table include ::Haml::Filters::Base def render(text) output = '
#{col} | } end output << "