Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
LessController.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.IO;
namespace MvcApplication1.Controllers {
public class LessController : Controller {
public ActionResult Get(string name)
{
string less = "";
using (var sr = File.OpenText(Server.MapPath("~/Content/" + name + ".less")))
{
less = sr.ReadToEnd();
sr.Close();
}
ViewData["name"] = name;
ViewData["less"] = less;
ViewData["css"] = lessCompiler.lessConverter.Convert(less);
return View();
}
public ActionResult Show(string name) {
string less = "";
using (var sr = File.OpenText(Server.MapPath("~/Content/"+name+".less"))) {
less = sr.ReadToEnd();
sr.Close();
}
ViewData["css"] = lessCompiler.lessConverter.Convert(less);
return View();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment