Including inline javascript using content_for in rails
Posted
by TenJack
on Stack Overflow
See other posts from Stack Overflow
or by TenJack
Published on 2010-03-17T17:54:12Z
Indexed on
2010/03/17
18:51 UTC
Read the original article
Hit count: 343
I am using content_for and yeild to inject javascript files into the bottom of my layout but am wondering what the best practice is for including inline javascript. Specifically I'm wondering where the put the script type declaration:
<% content_for :javascript do %>
<script type="text/javascript"> ... </script>
<% end %>
or
<% content_for :javascript do %> ... <% end %>
<script type="text/javascript">
<%= yield :javascript %>
</script>
<% end %>
I am using the first option now and wondering if it is bad to include multiple
...declarations within one view. Sometimes I have partials that lead to this.
© Stack Overflow or respective owner