Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7971205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:34:53+00:00 2026-06-04T07:34:53+00:00

I have the inherited the following string (I can do nothing about the format):

  • 0

I have the inherited the following string (I can do nothing about the format):

 <iframe \n  class=\"some_class\"\n  type=\"text/html\" \n  src=\"/embed/iframe_content.html?id=tsqA5D7_z10\" \n  width=\"960\" \n  height=\"593\" \n  marginwidth=\"0\" \n  marginheight=\"0\" \n  frameborder=\"0\">\n</iframe>

I am rendering it in an erb template like this:

<%= the_string %>

At the moment it renders as text like this:

&lt;iframe  class="some_class" type="text/html" src="/embed/iframe_content.html?id=tsqA5D7_z10" width="960" height="593"  marginwidth="0" marginheight="0" frameborder="0"&gt;&lt;/iframe&gt;

I need to render it as HTML.

I have tried the following:

  1. <%= the_string.html_safe %> # Renders the string unchanged
  2. <%= CGI.unescapeHTML(the_string) %> # Errors with a Type Error ‘can’t dup NilClass’
  3. <%= CGI.unescapeHTML(the_string).html_safe %> # Errors with a Type Error ‘can’t dup NilClass’
  4. <%= raw the_string %> # Renders the string unchanged

How can I render this string as HTML?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:34:55+00:00Added an answer on June 4, 2026 at 7:34 am

    As you seem to have noticed, there are two things you need to take care of:

    1. Unescaping the HTML entities
    2. Printing the raw html in your view

    For number 2 <%= raw ... %> should work fine.

    For number 1 CGI.unescapeHTML was the right idea, but I don’t think it recognizes all HTML entities so I would recommend taking a look at the HTML Entites gem

    You can also try and use the simple_format helper method, but I think you are going to have to pass it some options for it to allow the <iframe> tag

    also I would strongly suggest moving your unescaping logic into a helper method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code (inherited from someone): <div class=feedback>&nbsp;</div> <form onsubmit=return false autocomplete=off>
I have the following ValidationAttribute class [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] public
I have the following helper method in a ViewModelBase class, which is inherited by
I have the following class: public abstract class TableServiceEntity { protected TableServiceEntity(); protected TableServiceEntity(string
I have an entity with the following attributes public class DimensionElement { public string
I have the following code (inherited!) that will split a line of text into
Code which I have inherited keeps crashing out rather powerfully with the following error
I have the following code in specman that I inherited: some_method() is { var
I have inserted the following line into my Joomla template: <jdoc:include type=component /> This
I have defined an Event class: Event and all the following classes inherit from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.