0

I make a hash called timeOffsets in my code

@timeOffsets = Hash.new
total=0
@sections.each do |i|
  @timeOffsets[i.shortcode] = total
  total+=i.length
end

And I render it in Javascript using to_json, :

timeOffsets=<%[email protected]_json%>;

but I get it with the HTML entities encoded:

timeOffsets={&quot;Introduction_to_Lists&quot;:0,&quot;Removing_elements&quot;:693,&quot;Joining__join_&quot;:1490};

How do I stop it from encoding the HTML entities?

0

1 Answer 1

4
timeOffsets=<%=raw @timeOffsets.to_json%>

Use the raw view helper.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.