How do I import .less files with string interpolation in the pathstring?
Asked Answered
L

1

7

How do I import .less files with string interpolation in the pathstring.

@folder: "LessFiles";

I tried this

@import "@{folder}/file.less";

Error:
File Not Found. 
HTTP GET Url is "%7Bfolder%7D/file.less" 

and this:

@import formatString("{0}/file.less",@folder);

Error:
Server throws System.NullReferenceException

and this:

@path: "@{folder}/file.less";

@import @path;

Error:
directive block with unrecognised format on line 16 in file 'test.less':
 [15]: 
 [16]: @import @path;
       --------^
 [17]: 

Any tips how to solve this?

Thanks!

Levitt answered 11/9, 2012 at 12:5 Comment(4)
it is an upcoming feature in less.js and dotless but requires a lot of work to implement.Epley
Really? But it´s working for css attributes very well, e.g. its possible to define [background-image: url('@{image-folder}/loading-image.gif');], I´m wondering whats the difficult part.Levitt
imports are done at parsing and interpolation at evaluation.. need to get parsing to be allowed during evaluation.Epley
issue on github (thanks to Luke for working on it): github.com/dotless/dotless/issues/249Levitt
A
1

As of Less 1.4.0 variable interpolation is possible with @imports

Example

@bacon: "../bacon";

@import @{bacon}/smokey.less; 

More information can be found here - Less Language Features import statements

Apophyge answered 18/6, 2014 at 14:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.