title: Generating dynamic CSS using templates
body: <p>I want to generate dynamic CSS using templates and <code>Tilt</code> and<code>SASS</code> in <code>Rails 4</code>.</p>
  
  <ol>
  <li><p>Let's say I have the following <code>css.sass</code> template:</p>
  
  <blockquote>
  <pre><code>$class_name: test
  $width: 329 
  $height: 425 
  
  .view-#{$class_name}
  
    width: #{$width}px
    height: #{$height}px
  </code></pre>
  </blockquote></li>
  <li><p>I need <code>master.css.sass.erb</code> (I am not sure about the format) in which I am going to render my template as many times as I like with different parameters.</p></li>
  <li><p>In <code>application.css</code>, I am going to have something like this </p>
  
  <pre><code>*= require master.css.sass.erb
  </code></pre></li>
  </ol>
  
  <p>Each time I use the template with different parameters, I am going to add a line in my <code>master.css.sass.erb</code> file. I do not know how to pass parameters using <code>Tilt</code> to the <code>css.sass</code> template. Could anyone assist and tell if this is possible?</p>
  
  <hr>
  
  <p>This is what I have till now:</p>
  
  <ol>
  <li><p>The template <code>test.css.sass.erb</code>:</p>
  
  <blockquote>
  <pre><code>$color: &lt;%= color %&gt;
  body
    background: #{$color} !important
  </code></pre>
  </blockquote></li>
  <li><p>The <code>master.css.sass.erb</code> file:</p>
  
  <blockquote>
  <pre><code>&lt;%
      require 'erb'
      config_path = File.expand_path("../test.css.sass.erb", __FILE__)
      template = Tilt.new(config_path)
      template.render(self, :color =&gt; 'yellow')
  
  %&gt; .thisisrendered
      color: red
  </code></pre>
  </blockquote></li>
  </ol>
  
  <p>Note that the two files in one folder. The issue is that only the following css is renrered:</p>
  
  <pre><code>.thisisrendered
      color: red
  </code></pre>