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 6821165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:30:45+00:00 2026-05-26T21:30:45+00:00

I have some html content stored in a database field. I would like trusted

  • 0

I have some html content stored in a database field. I would like trusted admins in our system to be able to edit the HTML when needed. Eventually this html will be converted into an email message and sent to users. In addition to the static html content, the email message has a first and last name that is stored in an active record model.

I was hoping to leave the <%= user.firstname user.lastname %> inside the HTML text when the admins are editing the content and then eventally combine the content with embedded erb the email renderer. I have the part where the admins can save the HTML working fine.

However, even ignoring the email and just trying to render to a normal web page, I am not able to get a view to correctly substitute the embedded <%= ... %> with the information from the database. I always see the <%= ... %> instead of the substituted text. I have tried render_to_string, render :inline, etc.

In summary, I am trying to:

  1. Take some html text with embedded some erb from the database
  2. Run the text through a template where the embedded erb is replaced with the variables passed into locals
  3. Take the resulting text block and either email it to users or display on a web page depending on my needs

The problem is that the results always have the <%= ... %> in it instead of the substitutions.

In an example controller I have:

 def showit
    @storedhtml = mymodel.savedhtml
    @emailtext = render_to_string( template: 'e.html.erb',
      layout: false, locals: { user:@user })
   end

The e.html.erb contains:

<%= raw @storedhtml %>

and the showit.html.erb has:

= raw @emailtext

I have also tried using inline like this:

def showit
     # the line below is substituted but the <p> tags are not converted
    @stuff = "<%= '<p>testme</p>' + user.firstname %>"  
    @storedhtml = mymodel.the_html_content
    @output = render( inline: @storedhtml, locals: { user:@user }, layout: true )
end
  • 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-05-26T21:30:46+00:00Added an answer on May 26, 2026 at 9:30 pm

    I guess what you need is ‘liquid’ – it’s a template language for Rails.

    Check this out:

    http://liquidmarkup.org/

    http://railscasts.com/episodes/118-liquid

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

Sidebar

Related Questions

I have some random HTML layouts that contain important text I would like to
I have some content which in the database has linebreaks stored and when I
I have seen some mails which has HTML content embedded in them. The content
I have some content sliding here. http://www.smallsharptools.com/downloads/jQuery/Slider/slider.html The HTML structure is simple. There is
I have some HTML that looks like this: <ul class=faq> <li class=open> <a class=question
I have some HTML that looks like this: <div> <div class=value> <a href=# class=clicker>Some
I have content stored as raw text in a database that I show in
I have a large quantity of partial HTML stored in a CMS database. I'm
I have some HTML menus, which I show completely when a user clicks on
I have some HTML that displays fine on FireFox3/Opera/Safari but not with IE7. The

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.