Eliminate duplication in CSS with .less – a .NET HTTP handler


 

One of the frustrating aspects of working with CSS (one of many, actually) is the amount of duplication in a .css file. .less help to keep your CSS files DRY using 4 constructs:

  • Variables
  • Mixins
  • Operations
  • Nested Rules

image

An HTTP handler is configured to respond to requests for the .less files.

<httpHandlers>
    <add type="dotless.Core.LessCssHttpHandler, dotless.Core" validate="false" path="*.LESS" verb="*"/>
</httpHandlers>

When a request arrives for a .less file it is the handler’s job to parse the .less file and transform it into standard CSS rule sets.

Advertisements

One thought on “Eliminate duplication in CSS with .less – a .NET HTTP handler

  1. Vincent,
    Got anything to do CSS reduction within a handler? Overtime our CSS has gotten bloated and now exists across multiple CSS files. Many of the classes are never used. Removing the dupes and orphaned classes is a time consuming thing that I should do, but do you know of a handler that did this on the fly?

    Barry

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s