Variables defined in an imported file should be available to the parent and other later includes

Jon Leighton's Avatar

Jon Leighton

10 Aug, 2010 10:44 AM

Hiya,

Code speaks louder than words:

main.less

/* @myvar is not available here (obviously, as it's not defined */
@import "file1.less"
/* @myvar is not available here (but it would be nice if it was) */
@import "file2.less"

file1.less

@myvar: "foo";
/* @myvar is available here (obviously) */

file2.less

/* @myvar is not available here, but it would be nice if it was */
  1. 1 Posted by Travis Dahl on 01 Oct, 2010 05:28 AM

    Travis Dahl's Avatar

    I agree with Jon. I'd like to set up some basic utilities and variables to use across multiple .less files. This would be a killer enhancement.

  2. 2 Posted by Chris on 08 Nov, 2010 01:38 PM

    Chris's Avatar

    What I like to do is setup a master.less file, that has all my common variables and mixins, then have a template.less for my main layout/styles, then import the master inside of it.

    Furthermore the rest of my .less files would use the import of master.less

    Though what you're talking about is nice, mine is just a work around, lol

    ~ Chris http://twitter.com/TheCSSGuru

  3. 3 Posted by Tom on 19 Jan, 2011 10:54 AM

    Tom's Avatar

    I'd also love to see this happen.

    On larger sites, particularly those with white labels, it would be a beautiful thing to load a single .less file which set some variables and then imported library files which used those variables.

    One less file to rule them all.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac