Aug 10, 2009

Render without calling the controller's action in Merb

I was working on a Merb project in the company, I found a common request is generate the report to view in the browser and also send the report as an attachment of an email in a cron job. Usually I have to do two parts of job, one is for the regular MVC parts to get the report in a browser. Then I have to generate the report and write it a file(html, text or pdf). Then send it out later. As you might see, there is a duplication here, I have to design the report twice. This really bothered me, why can't I just re-use the view templates which is used in the MVC. After poking around the merb-core source files, it turns out pretty easy to do that:



This is another reason I love Merb.

No comments: