cloudhead/less.js — Issue #590: Issue with @import from subfolder on parent folder
Author: sindresorhus
Created: 2012-01-22 01:27:22+00:00
State: open

I have this file structure:

```
- test.js
- subfolder
- test.less
- subfolder2
- test2.less
```

test.js

```javascript
var fs = require('fs');
var file = fs.readFileSync('subfolder/test.less', 'utf-8');
require('less').render( file, function(e, css) {
console.log(css);
});
```

test.less

```less
@import 'subfolder/test2';
```

test2.less is empty.

---

When I run `node test.js`, I get this error:
`file 'subfolder/test2.less' wasn't found.`

The issue is that since we read the file in as a string, LESS doesn't know the context.

Maybe the `.render` method should also accept a context parameter?

Like:

```javascript
var context = 'subfolder';
require('less').render( file, function(e, css) {
console.log(css);
}, context );
```

Or let the first argument to the `.render` method also accept; a path to a file to render or a file buffer?