Running Less.js in C # / Javascript.net / V8

I am trying to run less.js in a C # application. I tried to run the default distribution using JavaScript.net , but I get an undefined error window. I think this is because it is not executed in the browser, but on the JS engine. Is there any workaround / any pointers to resources that might help?

+4
source share
3 answers

You should probably run . Less . If I understand correctly, you are trying to run less.js on the server through a Javascript interpreter. Why not just skip the interpreter and run the LESS transform using all the .NET code? Way less pain and overhead.

+8
source

This is more a guess than a real answer, but I will try to help, so please do not reduce if this is wrong. But according to the documentation (I have never worked with Javascript.net) the following is valid:

// Initialize the context JavascriptContext context = new JavascriptContext(); // Setting the externals parameters of the context context.SetParameter("console", new SystemConsole()); context.SetParameter("message", "Hello World !"); context.SetParameter("number", 1); // Running the script context.Run("var i; for (i = 0; i < 5; i++) console.Print(message + ' (' + i + ')'); number += i;"); // Getting a parameter Console.WriteLine("number: " + context.GetParameter("number")); 

Perhaps you should set the window as a parameter for the ala this context:

 context.SetParameter("window", new YourWindow()); 

And insure the window in which you provide have the same attributes / methods / etc. like a standard browser window.

Adding You can try and implement a simple window that simply writes to the console whenever a function is called on it. If not the reason, Javascript.Net gives you a window wrapper (although it doesn't look like it)

0
source

Less.js indicates that it is designed to run under Node.js. Since it looks like you're writing a .NET application, why not see if Node.net helps ?

0
source

Source: https://habr.com/ru/post/1315684/


All Articles