-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Escape function with nested var failed #3314
Comments
Have you tried first converting to a string? The You can perform the conversion inline with the escape operation by using the @color-icone : escape( %( "%s", #ffffff )); |
Sorry, just try but not working with inline string conversion. exactly the same error. |
Fews more tests : @color-icone : escape( #ffffff ); Both are working with Less 2.7.1. Both not working with Less 3.8.1 |
The less.js/lib/less/functions/string.js Lines 22 to 36 in a84358d
However, it calls less.js/lib/less/tree/color.js Line 70 in a84358d
@matthew-dean [EDIT] |
For svg issue, I've overrided
Original
For some reason, full replacement was failing, even in the plugin. |
Unfortunately, this error also occurs when it's not dealing with the color. (Example) I have tried the @easingtheme 's solution, and it seems working fine. Update:
So if we format the escape result to string, it seems working fine. .a {
@svg: %('%s', escape('<svg></svg>'));
--var: "data:image/svg+xml,@{svg}";
} |
The .a {
@svg : escape("<svg></svg>");
--var : "data:image/svg+xml,@{svg}";
} |
But even though it is quoted using the |
Finally i use that trick : Not working escape > throw syntax error :
Working :
|
Version
Less 3.8.1 via CodeKit
description
An error is thrown when escaping color variable and using it in an other var as string.
No error with Less 2.x
A less var, svg image for data-uri, with a nested less var "@color-icone" for fill color
@icone-arrow-next : "data:image/svg+xml;utf-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 49 37'><path fill='@{color-icone}' d='M31.1 0l-1.5 1.5 15.5 16H0v2h45.1l-15.5 16 1.5 1.5L49 18.5z'/></svg>";
Using the var elsewhere
#selector { @color-icone : escape(#ffffff); background-image : url( @icone-arrow-next ) ; }
The error come with the escape function which transform the color code '#ffffff' to '%23ffffff'.
No error without the escape function but the color string is not encoded...
error message
SyntaxError: Invalid % without number in /Users/path/to/file
The text was updated successfully, but these errors were encountered: