Haml based templates

map7 edited this page May 22, 2012 · 1 revision
Clone this wiki locally

Create a app/report/standard_report.rb file with the following

# Ruport module helpers
module StandardReport
  def haml(file)
    engine = Haml::Engine.new(File.read "#{Rails.root}#{file}")
    engine.render(self)
  end
  
  class HTML < Ruport::Formatter::HTML
    renders :html, :for => Ruport::Controller
  end
  
  def build_header
    @options = options
    output << haml("/app/report/header.html.haml")
  end
  
  def build_footer
    @options = options
    output << haml("/app/report/footer.html.haml")
  end
end

Now you can create a /app/report/header.html.haml & /app/report/footer.html.haml file.