-
Notifications
You must be signed in to change notification settings - Fork 1
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
classd tag doesn't act as promised in README #1
Comments
This is a WIP but I think updating classd to the below will fix the problem: function classd(strings, ...values) {
var res = '';
for (var i = 0; i < strings.length; i++) {
if (typeof values[i] === "object" && !Array.isArray(values[i]) && strings[i][strings.length - 1] !== " ") {
const prefix = strings[i].trim().split(" ").pop();
res += names.call(null, values[i]).trim().split(" ").reduce(function(acc, value) {
return acc + " " + prefix + value;
}, "");
} else {
res += strings[i];
res += names.call(null, values[i]);
}
}
return trim.call(null, res);
} All of the existing tests, as well as the new one passed with the above change in place. |
@mattvalleycodes , my apologies for this confusing scenario, the behaviour is intentional; but I had not updated the README. Here is the reasoning behind this behaviour : Consider the case classd`x-${{ y: true, z: true }}`
classd`${{ a: true, b: true }}-${{ x: true, y: true }}` In this case the values should be The recommended way for the current version is to prefix the individual object keys. I will update the README accordingly. In the next version, I will support prefixing in a safe manner. Thanks for reporting this. |
This approach would work for your testcase. But I think we can optimise it further. One key consideration in the classd package is the speed. |
The below code is copy/pasted from README:
padding-md
is generated as the result ofpadding-${{md: width > 960 && width < 1280 }}
. In reality, I getpadding md
!Node.js example
Unit test
and below test should technically speaking pass but it fails.
with the below error:
The text was updated successfully, but these errors were encountered: