-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Support json (to pass in arrays) #2601
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
You actually can pass an array of values via
E.g. just convert your JSON to a more Less-friendly structure ("direct" JS-like-object-as-array support would be strange since there's no corresponding language entities in either Less or CSS). |
this what about objects? i want something like this to work with less code above less({
modifyVars: {
glyphs: [
{
name: 'first glyph',
char: '1'
}, {
name: 'second glyph',
char: '2'
}, {
name: 'x glyph',
char: 'x'
}
]
}
}) also simple things like foreach must be simple not complex like this
|
Because Less is a CSS extension, not a JavaScript or PHP extension... (and CSS Technically, for an icon list you don't even need any array and a loop at all (as it can be generated via "list of mixins"), e.g.: .glyphs() {
// "array" of icons
.-(foo, "a");
.-(bar, "b");
.-(baz, "c");
.-(qux, "d");
}
// generate icons classes:
& {
.glyphs();
.-(@name, @icon) {
.@{name} {
content: @icon
}
}
}
See less-plugin-lists:at.
You can write your own mixin (5 lines of code) to hide whatever key/value extraction under either syntactic sugar (see http://stackoverflow.com/a/21441220, #2270 etc.). |
if you ask me this
looks more css-like then this
also i don't understand what is magic behind |
You compare different things (i.e. just
It's just a mixin name (replace with any you like more, e.g. |
okey |
so i have project https://github.com/thecotne/square-file-icons
i want change from lodash template to less
since it makes more sens for me to generate css with less
but i can't pass json to less.js
i can pass strings
but not objects and arrays of objects
i will be nice to support something like this
glyphs is array of objects passed from modifyVars
The text was updated successfully, but these errors were encountered: