Including inline javascript using content_for in rails
- by TenJack
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.