Can I parse LESS client side, and return the results?
I am currently using as recommended in documentation, which is to include less file, and minified less parser afterwards. I want to be able to return the raw css so I can save it as a css file.
I do not want to install node.js and the likes, I want a client side solution.
A look at the less.js source brings up the
Parserobject. Assuming thatless.jsis included in the page:will output the following to the console:
The constructor for
less.Parseractually takes series of settings, and I don’t understand enough of the internals of LESS to say what might be good to pass (though they are all optional so passing none should just use the defaults).The
Parser.parsemethod takes two parameters: a string containing the LESS file, and a callback that handles the parsed data. The callback receives up to two parameters, an error object (error) and an object representing the parsed LESS (root).rootisn’t passed if there was a fatal error, anderrorwill benullif there was no error.Unfortunately, I can’t find any better documentation on the attributes of the error parameter than the place they are set in the source here.