1

Trying to pass string data produces the desired result in HTML but not sure why I am getting "missing ; before statement" error.

<%= javascript_tag do %>
    window.context_user_email = <%= @context_user_email %>;
<% end %>

gives...

<script type="text/javascript">
//<![CDATA[

        window.context_user_email = [email protected];

//]]>
</script>

2 Answers 2

2

If you add quotes it will become a string variable, otherwise it is just a syntax error:

<%= javascript_tag do %>
    window.context_user_email = "<%= @context_user_email %>";
<% end %>
Sign up to request clarification or add additional context in comments.

Comments

2

[email protected] should be quoted like

"[email protected]" 

<%= javascript_tag do %>
    window.context_user_email = "<%= @context_user_email %>";
<% end %>

since it must be read as a string-value

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.