I am storing ERb templates in the database and would like to use them for things such as emails, pdf generation, etc.
I was able to create this functionality with this method (see attached).
def render_string_to_string(text = nil, type = "rhtml") #:doc:
add_variables_to_assigns
@template.render_template(type, text)
end
Which I could call like so:
foo = render_string_to_string(letter_template.body)
With render_template(), it would output to the browser. render_string() required a physical file on the system as a template.
Is there a better way to do this? I noticed that in the trunk, render* is completely refactored, so maybe this isn't the case anymore?