If they MUST be dynamically generated, I would suggest creating the base Sass file, generate the CSS, then create a .css.erb template that can render the difference between them. At one time I created a Rails template handler that did just that, but kept the Sass in its original form and interpreted the ERb first. The only way I got away with this is because the result was page-cached. Not recommended in general!
Sean Mislav Marohnic' wrote: > I don't think Sass will ever process Ruby code. You have to rethink > your design. > > As for your #1: why do you need this? Simply combine separate > stylesheets with the fact images are looked up relatively to the > location of *.css file. > > #2 and #3 are already handled by Sass import feature. > > And as for theming your site or having users define some styles: you > can use Sass for that, too. Simply use Sass::Engine directly in your > app, but interpolate the origin string with as much Ruby as you want. > Then convert to CSS and render inline in HTML layout or save to a file > on disk and then include it. > > I think we'll be more able to help you once we find out your ultimate > goal. > > On Tue, Apr 22, 2008 at 11:38 PM, zubin <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> wrote: > > > Apologies if this is the wrong place to post SASS questions - I > couldn't find a separate SASS forum so here goes... > > Is it possible to insert Ruby code in a SASS file? > > The reason is because I need two separate stylesheets which are almost > identical, and I want to keep things DRY (the only difference is the > graphics path). > > My initial plan was something like this: > > 1. Create a SASS "template" file (called template.sass) which uses > __FILE__ to define graphics path: > > !template_path = "/images/#{File.basename(__FILE__)}" > #header > :background = "url(" + !template_path + "/bg.jpg)" > > 2. Link required sections to it: > > ln -s template.sass section1.sass > ln -s template.sass section2.sass > > 3. Link to stylesheet for current section (note: sections are sharing > the same layout file): > > # in application.html.haml > = stylesheet_link_tag @template > > But I got stuck at step 1. Any suggestions? Is there a better way? > > PS - Thank you Hampton, Nathan and Jeff for haml (and sass of course) > - brilliant code and documentation! As suggested in the docs, it _has_ > inspired me to write cleaner code. Nice work! And make_resourceful is > awesome too... > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Haml" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/haml?hl=en -~----------~----~----~----~------~----~------~--~---
