I'm kind of stuck on a problem and I need help getting around it.
I'm developing a Rails 3 app that will allow users to interact with our email service provider via SOAP services. Users will be able to upload full HTML files which will be stored in the app's database (MySQL). I'm trying to create a view that will give the user a preview of the HTML content saved on the database.
More often than not, the HTML documents will have some type of styling applied to the background (like <body bgcolor="#e5e5e5"> or <div style="background:#e5e5e5;"> or both. That styling gets applied to the entire page. Where I'm stuck is creating a container for the inline HTML that will constrain those styles. I was thinking <iframe>, but that seems to want a src attribute, but the source of my HTML is the database. Any ideas how I would accomplish this?
Here's the view code I have:
<p>Content for: <%= @doc.file_name %> </p> <div> <%= render :inline => @doc.content %> </div> Here's the source code of the rendered HTML page if that helps you to visualize what I'm doing:
<!DOCTYPE html> <html> <head> <title>ListTool</title> <meta name="csrf-param" content="authenticity_token"/> <meta name="csrf-token" content="W7AoMYkiW8gDdKYDNB/NemCY/mRz+JeNadb3pexhaIo="/> </head> <body> <p>Content for: HJ4151.html </p> <div> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>The Bankers’ Black Book of High-Yield Dividend Plays </title> </head> <body marginheight="0" marginwidth="0" topmargin="0" bgcolor="#e5e5e5"> <div style="width:100%; background:#e5e5e5; margin:0; padding:0;"> _irrelevant HTML code here_ </div> </body> </html> </div> </body> </html>