Basically, I have a class that outputs some html:
class Foo
include ActionView::Helpers
def initialize(stuff)
@stuff = stuff
end
def bar
content_tag :p, @stuff
end
end
so I can do: Foo.new(123).bar
and get “<p>123</p>”
… But what I really want to do is something like this:
class Foo << ActionView::Base
def initialize(stuff)
@stuff = stuff
end
def bar
render :template => "#{Rails.root/views/foo/omg.html.erb}"
end
end
# views/omg.html.erb
<h1>Wow, stuff is <%= @stuff %></h1>
and then do Foo.new(456).bar and get “<h1>Wow, stuff is 456</h1>”
Just call erb directly? Something like: