-
Notifications
You must be signed in to change notification settings - Fork 3.4k
allow undefined variables to be falsy - bad recursive variable declaration error #1494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Solved this issue by doing:
|
I thought that fixed it, but when @themeColorPath is undefined I am getting a recursive variable definition error:
As far as I can tell, there is nothing recursive about the code. If I remove the @import and just try to declare the variable with the ternary, I get the following, which I assume is another complaint about an undefined variable:
This is my code:
It appears to me the compiler errantly considers something recursive which isn't. |
Hi, Please could you give us a full repro example? the example you say is your code.. what file is that? what other files are there? |
The goal I am trying to achieve is to be able to compile themed versions of the stylesheets. So I want to be able to compile main.less to main.css and theme-main.less to theme-main.css. My intention is to add theme-main.less as a layer above main.less and change the path it uses to import colors.less and variables.less main.less :
When I try to compile with main.less as src, I get the recursive declaration error:
with theme/theme-main.less as:
When I compile with theme/theme-main.less, it compiles and imports as expected. |
I'm running into this same issue using a very similar set-up, could see this solved by either allowing undefined values in guards or allowing any sort of "default value" setup with |
Just in case, this can be achieved without any conditionals, for example: // .........
// main.less
.default-paths {
@colorPath: 'colors.less';
@variablePath: 'variables.less';
} .default-paths;
@import '@{colorPath}';
@import '@{variablePath}';
// ..........
// theme.less
@colorPath: 'theme/colors.less';
@variablePath: 'theme/variables.less';
@import 'main.less'; Basically, variables defined in |
Awesome, thx @seven-phases-max, that's exactly what I was looking for. |
Closed as duplicate of #1400. |
I would like to do some theme switching using a variable "colors.less" file, but guarded expressions aren't quite doing what I would expect. My hope is that when calling a guarded mixin, undefined variables won't throw an error but will rather be treated as falsy:
in theme-main.less:
in main.less:
In javascript, an undefined variable is falsy, so I would expect "when not(@themeColorPath)" to be satisfied if @themeColorPath isn't defined, but instead the compiler complains.
I'm not sure of any other way to dynamically load "colors.less" based on what a theme-main.less defines
The text was updated successfully, but these errors were encountered: