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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:50:23+00:00 2026-06-16T23:50:23+00:00

I try to initialize a JavaScript variable in a .js.erb template with a text

  • 0

I try to initialize a JavaScript variable in a .js.erb template with a text having new lines, and special characters like ” > , ” “. To visualize this text, think about the long email conversations, earlier reply lines start with char “>”.

Text is fetch in the rails’ controller, and initialize a ruby variable with it. So, I use the following line to complete the process, but it fails (might be cause of new line). However, I think it’s very common case to have such a string values in daily web programming. How do you overcome this issue (jQuery options are welcomed)

var jstext = "<%= @rails_long_text %>";
  • 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-16T23:50:25+00:00Added an answer on June 16, 2026 at 11:50 pm

    Do:

    var jstext = "<%=j @rails_long_text %>";
    

    This will escape the content to fit js expectations.

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

Sidebar

Related Questions

When i try to initialize velocity engine using VelocityEngine engine = new VelocityEngine(); engine.init();
Usually, when I try to initialize a static variable class Test2 { public: static
In JavaScript, you can define an object like this: var d = {1: 'test'};
I'm having this strange problem when i try to access elements in json from
I am new to javascript plugins. So this is my question pertaining to it
Hi I'm new to Typescript and Javascript and I'm having a few problems creating
When I try to initialize an object using the Object Initializer, ReSharper always inserts
When I try to initialize the speech recognizer with the following code: SpeechRecognizer rec
I want to learn and work with initialize.php so I try to build simple
Gut-feeling: It looks a little bit like two threads both try to initialise disk-based

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.