documentcloud / jammit

Industrial Strength Asset Packaging for Rails
http://documentcloud.github.com/jammit/
MIT License
1.16k stars 197 forks source link

turn off embedding on a per-package #10

Closed agibralter closed 14 years ago

agibralter commented 14 years ago

I'm using compass/blueprint in my CSS and it uses an IE6/7-only stylesheet:

    /[if lt IE 8]
      = stylesheet_link_tag 'compiled/ie.css', :media => 'screen, projection'

I was thinking I would use the Jammit include_stylesheets helper just for consistency in code and in keeping all my assets in public/assets; however, this causes trouble because of double HTML comments... If I do:

    /[if lt IE 8]
      = include_stylesheets :ie, :media => 'screen, projection'

I get:

<!--[if (!IE)|(gte IE 8)]><!-->
<link href="/assets/ie-datauri.css?1259696203" media="screen, projection" rel="stylesheet" type="text/css" />
<!--<![endif]-->
<!--[if lte IE 7]>
<link href="/assets/ie.css?1259696202" media="screen, projection" rel="stylesheet" type="text/css" />
<![endif]>
<![endif]>

I know this is a bit of a corner case, but perhaps some something like

include_stylesheets :ie, :media => 'screen, projection', :no_embed => true

would make sense. Any thoughts?

documentcloud commented 14 years ago

Sure. The root of the problem is that you're trying to use conditional comments, Jammit's trying to use conditional comments, and the two don't get along. Would you like to see an option like :ie_only => true, which would remove the (!IE) portion? Or would you rather see an :embed_images => false option, which would return the regular version of the stylesheet for that package only. I'm partial to the latter. If I read your suggestion correctly, that's what you're suggesting.

documentcloud commented 14 years ago

Alright -- I've got a patch for :embed_images => false as an allowed option to the include_stylesheets helper. It will turn off embedded images for just that single asset package, giving you the plain script tag without any conditional comments. Check out the latest version and give it a spin -- you can run rake gem:install to build a gem for yourself. If it works for you, we can push out a Jammit 0.3.2...

agibralter commented 14 years ago

Alright, sorry for the delay. I tried it out, and it seems to work great. Thanks!

documentcloud commented 14 years ago

Fantastic. Jammit 0.3.2 is out, with the patch. Closing this ticket.