-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove extra javascript content blocks. #1842
Conversation
<%= yield :javascript_libraries %> | ||
<%= yield :after_javascript_libraries %> | ||
<%= javascript_include_tag 'application' %> | ||
<%= yield :javascripts -%> | ||
<% if request.env['HTTP_USER_AGENT'] =~ /MSIE/ %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've rearranged this, but this might be in error. My rationale was that users should be given the opportunity to insert any stylesheets before Refinery's (albeit minimal) stylesheets are loaded, but I'm concerned that this might result in errors if the user is on IE6 and loads some library with PNGs. @parndt WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know about doing this without deprecating first. You can use this functionality to warn the user:
<% if content_for? :before_javascript_libraries %>
<% Refinery.deprecate "content_for :before_javascript_libraries", :when => '2.2', :replacement => "content_for :javascripts" %>
<% content_for :javascripts, yield(:before_javascript_libraries) %>
<% end %>
<%= yield :javascripts %>
It complicates the view but is somewhat necessary.
Also this means you have no way to specify the order so you need to put all libraries inside application.js
-- correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I guess it's somewhat necessary to deprecate. Alas.
As far as order goes, if you need to append anything, you can do it with content_for :javascripts. Anything beforehand needs to be in application.js
... as it should be, in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree with the application.js
If you can add the deprecation code that'd be awesome.
Should we take this opportunity to move to a helper method or PORO (Plain Old Ruby Object) or should we continue using content_for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add those deprecation statements shortly.
content_for
should suffice. Let's not overcomplicate things — if we were keeping the ability to prepend or append scripts, I might be in favour of that, but as it stands, being able to just yield a block is pretty useful.
…-blocks Remove extra javascript content blocks.
In concert with #1841, this removes the extra sections of Javascript that aren't necessary anymore with the asset pipeline.
It should be debated whether the
:javascripts
content block has use anymore; I think that it still does, but I'm definitely open to arguments.