ActionView Standalone

require 'action_view'
require 'action_controller/mime' # for Rails 2

render :file=>'foo.html.erb', :locals=>{:user=>User.first}
render :file=>'lib/data_feed.xml.builder', :type=>:rxml, :locals=>{:user=>User.first)

def render(options)
  klass = Class.new(ActionView::Base)
  klass.class_eval{ def url_for(x);x;end } # to be able to use link_to
  klass.new.render(options)
end

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s