Found this library a couple of days ago and thought it would be really great for bigger projects. Maybe in the future kooboo can integrate DotLess functionality also.
The library I am talking about is
http://github.com/jetheredge/bundler. It looks very simular to what Kooboo does with JS and CSS files. The only difference is that it supports
DotLess.
For those that don't know DotLess or Less I'll try and give a short explanation. DotLess is a port from the ruby library Less for asp.net. The biggest advantage to me is that you can write nested styles. This means you don't have to repeat yourself and for me it's alot more readable. It also has some other advantages over CSS but you can read that on their website.
Regular CSS:
Code:
#Content
{
color: blue;
}
#Content a
{
background-color: orange;
}
With DotLess you can write it like this:
Code:
#Content
{
color: blue;
a
{
background-color: orange;
}
}
You can also use the DotLess library directly in Kooboo ofcourse but I didn't want to change to much of the default kooboo code.
To use bundler get the library from github. Then you have to add the Bundler.Framework.dll to your kooboo bin folder. You only need that dll all the other dlls that go with the Bundler framework are already included in Kooboo.
After you did this you have a few options to use Bundler. The way I did it is to make a "Less" folder inside "theme/default". I then used the bundler framework to render that file to my "theme" folder.
To do this my LayoutTemplate looks something like this:
Code:
<head runat="server">
<title runat="server"></title>
</head>
<body>
<% Bundle.Css()
.Add("/Template/ApplicationName/BinaryResource/theme/default/less/main.less")
.Render("/Template/ApplicationName/BinaryResource/theme/default/Main.css");%>
</body>
Because I use <% and not <%= the string doesn't get written to the output but the file gets render. Kooboo will see the file in the theme folder and add it to the head of your page. This way the css files get minified twice though but I don't think it's a big problem.
Hope this helps for people wanting to use DotLess with Kooboo.