Daniel Hoelbling-Inzko talks about programming
After a lot of work we finally released a new version of dotless. And this release is really sweet. We switched parsers from the troubled PEG parser we had to an all-new implementation of the less.js parser that gave us a ton of room for improvements and little tweaks.
Here’s a rundown of the most important features:
New parser also means we finally have meaningful error messages and if there are syntax errors we tell you what line the error occured and what went wrong. So that’s a huge improvement for all the people who saw empty .css files trying to figure out what broke the compilation.
One thing users have been asking us for are parameters to be passed to the scripts. We finally found a good way to implement this and now it’s in.
If you use the HttpHandler you can simply pass parameters through the querystring. Let’s say you have a basecolor you want to pass to your .less file you simply call it from the site like this:
and the variable @basecolor will be set to #34679a for you in your script. This is especially handy if you are using the HSL functions where you can modify saturation, lightness etc.
If you are using the console compiler you can also leverage this new functionality through a very Ant like parameter syntax:
dotless.Compiler.exe test.less –Dbasecolor=%2334679a
Note: Parameters in querystrings have to be URL encoded or some browsers will act up.
We also made sure that the cache works properly with parameters, so if two requests have the same parameters the cache will be used. If not, dotless will insert for every parameter/file combination one cache entry. Since parameters are by no means user-input values but usually limited to a set of values the designers specify this should still give you very good performance. Behind the scenes we are still using the ASP.NET cache infrastructure.
While at the topic of caching, we also improved cache invalidation. The old version did not watch all imported files for changes but only the main .less file. This has changed, you should now never have to think about disabling the cache during development.
The same change was also applied to the console compiler, if you start it with –watch the compiler will regenerate the CSS whenever any of the imported changes or the main file gets changed.
Runnable in medium trust
Well, nothing really exciting here, but you should now be able to run dotless in a shared hosting environment.