Capture Generated HTML

My app generates a web page.
What I would like to do is capture the final HTML output of the rendered page, after my code has constructed it with a variety of partials, into a variable so that I can tell the ‘swoosh’ emailer to use this captured rendering as the email’s body content.

Does anyone know how I could do this?

I think you can call:

https://hexdocs.pm/phoenix/Phoenix.View.html#render/3

To get the template.

1 Like

You probably want Phoenix.View.render_to_string/3 to get the iodata “flattened” out.

3 Likes

Thanks people.

paulsuulivanjr pointed me in the right direction and at the bottom of the HexDoc, I found the render_to_string()/3 function.