Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include LESS Variables in CSS @import Directive

Tags:

css

less

I would like to include a LESS variable inside the string content of my @import statement . . .

@my-font-name: Georgia;
@import "http://fonts.googleapis.com/css?family=Open+Sans:400,300,600|@{my-font-name}:400,300,700";

However, in the processed CSS, there is no transformation and it just looks the same:

@import "http://fonts.googleapis.com/css?family=Open+Sans:400,300,600|@{my-font-name}:400,300,700";

where I would prefer it to be processed like this:

@import "http://fonts.googleapis.com/css?family=Open+Sans:400,300,600|Georgia:400,300,700";

Is there any solution?

like image 902
blaster Avatar asked Jan 14 '23 23:01

blaster


2 Answers

I'm on the core team for less.js, variables in @import statements was introduced in . Less.js v1.4.0-b1

This should allow you to accomplish what you're looking to do:

@my-font-name: Georgia;
@import "http://fonts.googleapis.com/css?family=Open+Sans:400,300,600|@{my-font-name}:400,300,700";
like image 123
jonschlinkert Avatar answered Jan 18 '23 09:01

jonschlinkert


You cannot currently do this in Less, however it does look like the feature maybe coming soon.

More precisely its in less.js 1.4 alpha.

https://github.com/cloudhead/less.js/issues/410

like image 23
JohnC Avatar answered Jan 18 '23 09:01

JohnC