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

  • SEARCH
  • Home
  • 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 9229201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:30:48+00:00 2026-06-18T05:30:48+00:00

In Sinatra, using erubis, the default setting for escape_html is true . But sometimes

  • 0

In Sinatra, using erubis, the default setting for escape_html is true.

But sometimes I want to to unescape, because, I do not want to add too much escape_html. Don’t repeat yourself. 🙂

helpers:

def raw(string)
  CGI::unescape_html(string)
end

views:

<div class="body">
  <%= raw "<h1>Thanks for help...</h1>" %>
</div>

does not work.

  • 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-18T05:30:49+00:00Added an answer on June 18, 2026 at 5:30 am

    Not sure about which version of Erubis you use, but it seems like it has a special kind of tag for that particular case: with two equals signs. So the line from your example might look like:

    <%== "<h1>Thanks for help...</h1>" %>
    

    Calling to CGI::unescape should not be necessary, because the string is initially not escaped. All you need is to prevent escaping, not undo it.

    But if your Erubis don’t understand <%==, or if you use ERB, not Erubis, then sorry, I don’t know any other solution except of what you said: disable html escape for entire file and use h everywhere you do need escaping.

    FYI, in Rails for this also there are special helpers raw and String#html_safe, but as I can see they are part of ActiveSupport and not available in Sinatra.

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

Sidebar

Related Questions

I'm deploying a Sinatra app using passenger. The deployed app is working, but not
I am not using Rails, but I'm using Sinatra, Sequel and some asynchronous messaging
I am trying to test a sinatra app using minitest and capybara but get
I am using Sinatra but I am guessing this also applies to Rails (if
I have been using Sinatra for sometime now and I would like to add
I am building an Ruby application using Sinatra (over Rack/Thin) and I want to
Ok, so I'm not having trouble with this per say, but I want to
I am working on a project using sinatra with haml for templates. I want
I'm using Sinatra and Ruby 1.9.3. I have a list of items and want
I'm working in a Sinatra application using Sequel. I want to make a transaction,

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.