asual/lesscss-engine — Issue #22: @import in relation to String source
Author: sroebuck
Created: 2011-12-22 18:37:14+00:00
State: open

When compiling less source from a String, `@import` statements don't work, presumably because the `@import` statements are interpreted relative to the location of the source file.

It would be helpful if there was a `compile `method that could take a `String` and a root file path and use the root file path as the root for paths in `@import` statements.

The reason for wanting this is to allow less to be used for scripting CSS within a web template engine. The less code _does_ exist in the filespace but is only part of a file, not a whole file, so I need to pass the content as a String.

I have tried saving the String as a temporary file and then using the `compile` method that takes a file. However, when I use an absolute file reference for my `@import` I find that the absolute reference has been concatenated to the end of the directory containing the temporary file. In other words, it appears that the underlying `less.js` code may only be able to cope with relative paths.