23

I'm getting slightly jealous of the innovation I'm seeing from the Python and Ruby community around CSS. For example, see:

  1. http://sandbox.pocoo.org/clevercss/
  2. http://lesscss.org/
  3. http://sass-lang.com/

That said, my question is two fold. Could these library's be easily "ported" to .NET via IronRuby and IronPython so I could then write MSBUILD tasks or HTTP Handlers in C#?

Also, should I bother with this, or is someone else in the .NET community already working on this?

UPDATE: Since I wrote this original question, there has been a lot of work in the .NET community in this space. Check out the following tools that provide assistance for LESS, SASS and even CoffeeScript:

nikmd23
  • 9,095
  • 4
  • 42
  • 57

4 Answers4

23

http://www.dotlesscss.org/ - My attempt at playing around with Less for .NET.

Dmytrii Nagirniak
  • 23,696
  • 13
  • 75
  • 130
Owen
  • 6,992
  • 7
  • 44
  • 77
20

It would be nice to port SASS to .NET, because it's such a nice tool and .NET is such a nice platform. But there's not really much need, because we can continue to use the Ruby tool as-is. You can very easily add a step to your build process which compiles SASS files into CSS files using the Ruby tool.

Here's mine.

#PostBuild.rb
#from http://sentia.com.au/2008/08/sassing-a-net-application.html
#Post-build event command line: rake -f "$(ProjectDir)PostBuild.rb"

require 'haml'
require 'sass'

task :default => [ :stylesheets ]

desc 'Regenerates all sass templates.'
task :stylesheets do
    wd = File.dirname(__FILE__)
    sass_root = File.join(wd, 'Stylesheets')
    css_root = File.join(wd, 'Content')
    Dir[sass_root + '/*.sass'].each do |sass|
        css = File.join(css_root, File.basename(sass, '.sass') + '.css')
        puts "Sassing #{sass} to #{css}."
        File.open(css, 'w') do |f|
            f.write(Sass::Engine.new(IO.read(sass)).render)
        end
    end
end
yfeldblum
  • 65,165
  • 12
  • 129
  • 169
  • This worked great with a few tweaks. Prevented files starting with _ from getting generated and also had to add Dir.chdir(sass_root) to allow importing to work. – statenjason Oct 16 '09 at 17:27
  • 1
    I'd really like to have a SASS view engine for ASP.NET MVC so that I could execute code in the CSS view itself (eg. inserting correct paths for content so that the site works in different hosting scenarios) and then enable output caching. Anyone doing something like that? – Drew Noakes Sep 02 '10 at 23:23
  • Now sass supports the -watch parameter, so it can watch for changes in scss files and compile them on the fly (like less with node). –  Nov 21 '12 at 10:02
3

I use this, it rocks!

got to read these links: http://www.hanselman.com/blog/CoffeeScriptSassAndLESSSupportForVisualStudioAndASPNETWithTheMindscapeWebWorkbench.aspx

http://www.mindscapehq.com/products/web-workbench/getting-started

PDA
  • 766
  • 6
  • 10
  • As of this writing (end of 2012) the Mindscape Workbench doesn't support sass --debug-info, which is very very helpful with firesass and chrome experimental sass debug options. –  Nov 21 '12 at 10:04
2

CSS Variables can be accomplished with HTTP Handlers.

http://www.webpronews.com/blogtalk/2006/10/16/add-variables-to-standard-css-stylesheets-in-aspnet

I imagine a lot of the other useful features exist in some form, which are you interested in specifically?

Bob
  • 97,670
  • 29
  • 122
  • 130
  • 2
    PS: Mads Kristensen has a lot of other fun http handlers and things on his blog http://madskristensen.net/default.aspx – Bob Jun 26 '09 at 14:38
  • 1
    +1. I wonder why would anyone miss [Web Essentials extension](http://vswebessentials.com/) for VS2012 in RIA development discussion! – Annie Mar 26 '13 at 22:20