How do I get escape_javascript and other helpers in my sprockets pre-processed js file (not a view)?

You can include the rails JS helpers into your own class.

You can include the rails JS helpers into your own class. Class Helper include ActionView::Helpers::JavaScriptHelper def self. Escape_js( text ) @instance ||= self.

New return @instance. Escape_javascript( text ) end end Then use it in your ERB file: obj = { name: "test", tag: "" }.

Thanks, this worked! I put that class at the top of my js. Erb file – nocache Jul 27 at 4:35.

You may also either include JavaScriptHelper directly into the Sprockets Context class (the class that runs your template): Or even define your helper somewhere else and include that in the template (so as to be able and reuse the helper).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions