Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think that if that is the path you want to take you should create a IHttpHandler to replace the dotless LessCssHttpHandler. This handler would perform basically the same actions as the LessCssHttpHandler but would insert the database variables into the less prior to compiling into css. </p> <p>You can look at the <a href="http://bundletransformer.codeplex.com/SourceControl/latest#BundleTransformer.Less/Translators/LessTranslator.cs" rel="noreferrer">Bundle Transformer</a> LESS project which does less translation using dotless. It also has a IHttpHandler that you could base yours off of. </p> <p>As others have stated this might not be the best course of action</p> <p><strong>Edit:</strong> Basic starting point for the Handler</p> <pre><code>public class LessHandler : IHttpHandler { public void ProcessRequest(HttpContext context) { var request = context.Request; var response = context.Response; var user = context.User; string assetUrl = request.Url.LocalPath; string assetPath = context.Server.MapPath(assetUrl); //load less file into the data. var data = ""; using (var file = new StreamReader(assetPath)) { data = file.ReadToEnd(); } DotlessConfiguration lessEngineConfig = DotlessConfiguration.GetDefault(); lessEngineConfig.MapPathsToWeb = false; lessEngineConfig.CacheEnabled = false; lessEngineConfig.DisableUrlRewriting = false; lessEngineConfig.Web = false; lessEngineConfig.MinifyOutput = true; lessEngineConfig.LessSource = typeof(VirtualFileReader); var lessEngineFactory = new EngineFactory(lessEngineConfig); ILessEngine lessEngine = lessEngineFactory.GetEngine(); string vars = ""; //TODO set default for vars if (user != null) { //TODO get vars for user } var content = lessEngine.TransformToCss(string.Format("{0}{1}", vars, data), null); // Output text content of asset response.ContentType = "text/css"; response.Write(content); response.End(); } public bool IsReusable { get { return true; } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload