Last week I released a new minor version of the Helperful GEM. This is essentially a bugfix release, although it comes with one minor new feature: the javascript_content_for
tag. The following overview is taken directly from the documentation.
The javascript_content_for
helper combines the features of content_for and javascript_tag into a single helper.
<% javascript_content_for :head do %>
$("#id").hide();
<% end %>
The block is passed as it is to javascript_tag
, then the result is stored as content_for :head
.
Now you can call yield and output your javascript content.
<%= yield :head %>
<script>$("#id").hide();</script>
This example is equal to the following statements.
<% javascript_content_for :head do; javascript_tag do %> $("#id").hide(); <% end; end %>
<% javascript_content_for :head do %>
<script>$("#id").hide();</script>
<% end %>
This feature also addresses an annoying bug in the has_content
helper method caused by an undefined variable.
To install or upgrade:
gem install weppos-helperful --source http://gems.github.com
More features still to come. Visit the project page for further details.