Reputation: 95
I am trying to put font family for a div if the variable is not equal to null. my less code is
div.content {
& when (isstring(@contentFont)) {
font-family: @contentFont;
}
}
the output that I get from css is
div.content when (isstring(@contentFont)) {
font-family: Abel;
}
my problem is, the style is not applying for the div.content, not sure what i am doing wrong. Any help would be greatly appreciated.
Upvotes: 2
Views: 2388
Reputation: 7317
As discussed in the comments, you're using version 0.4.0 of lessphp
– which doesn't seem to support the shorthand guard (when
) syntax that you're trying to use.
It looks like it does support guards on mixins, however.
Try splitting your code into a mixin and a usage of this mixin, like this:
/* the mixin */
.fontIfString(@font) when (isstring(@font)) {
font-family: @font;
}
/* usage */
@contentFont: "hello";
div.content {
.fontIfString(@contentFont);
}
Upvotes: 1