Skip to content
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

Merged
merged 1 commit into from
Aug 9, 2012

Conversation

robyurkowski
Copy link
Contributor

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.

<%= yield :javascript_libraries %>
<%= yield :after_javascript_libraries %>
<%= javascript_include_tag 'application' %>
<%= yield :javascripts -%>
<% if request.env['HTTP_USER_AGENT'] =~ /MSIE/ %>
Copy link
Contributor Author

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?

Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

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.

@travisbot
Copy link

This pull request fails (merged 84581b6 into 58e24df).

@travisbot
Copy link

This pull request fails (merged 7c423408 into 58e24df).

@travisbot
Copy link

This pull request passes (merged 7501df3 into 47584ae).

ugisozols added a commit that referenced this pull request Aug 9, 2012
…-blocks

Remove extra javascript content blocks.
@ugisozols ugisozols merged commit b0d9719 into master Aug 9, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants