title: In Rails, how can I include a style sheet from the asset pipeline as a <style> tag?
body: <p>Everyone knows how to use <code>stylesheet_link_tag</code> to <em>link</em> to a stylesheet, but I would like to actually include an entire stylesheet in a page itself. (No, this is normally not a great practice, but it makes sense in this context.)</p>
  
  <p><code>stylesheet_include_tag</code> does not exist, and a co-worker who is a much bigger bad-ass at Rails than I am says there isn’t a simple way.</p>
  
  <p><strong>Question:</strong><br>
  Is it actually possible to make use of the asset pipeline <em>and</em> still embed the contents of a CSS or JavaScript file (compiled from Sass or CoffeeScript!) into a <code>.haml</code> view? How?</p>
  
  <hr>
  
  <p><strong>Added</strong> for clarity:</p>
  
  <p>I’d like for my layout to be able to include something like:</p>
  
  <pre><code>= stylesheet_link_tag "base"
  = stylesheet_embed_tag "page-specific-styles/foo"
  </code></pre>
  
  <p>And have this generate output HTML along these lines:</p>
  
  <pre><code>&lt;link rel="stylesheet" href="/base.css" /&gt;
  &lt;style type="text/css"&gt;.foo { color: red; }&lt;/style&gt;
  </code></pre>
  
  <hr>
  
  <p><strong>Update</strong></p>
  
  <p>It’s possible to use Sass within Haml if you <a href="https://gist.github.com/alanhogan/6290026" rel="noreferrer">set your initalizer correctly</a>, but I cannot seem to <code>@import "foo"</code> from this context, where <code>foo.css.sass</code> is a stylesheet in the asset pipeline. Note that <code>@import "compass"</code> (assuming you have the compass gem) does work. </p>
  
  <p>This looks like (haml):</p>
  
  <pre><code>%style
    :sass
      @import "foo"
  </code></pre>
  
  <p>Rails gives an error that "foo" cannot be found, even though it claims to be looking in <code>app/assets/stylesheets</code> (which is where <code>foo.css.sass</code> lives).</p>
  
  <p>So, this feels closer, but still not quite there.</p>