Skip to content

allow undefined variables to be falsy - bad recursive variable declaration error #1494

Closed
@sojournerc

Description

@sojournerc

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:

@themeColorPath: '/theme/colors.less';
@import url('main.less');   

in main.less:

.themeOn (@themeColorPath) when not (@themeColorPath) {
@colorPath: 'colors.less'
}
.themeOn (@themeColorPath) when (isstring(@themeColorPath)) {
@colorPath: @themeColorPath;
}
.themeOn(@themeColorPath);
@import url(@colorPath);

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions