Skip to content

Add support for one element lists #64

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

Merged
merged 1 commit into from
May 29, 2018

Conversation

dentrado
Copy link
Contributor

Currently { "colors": ["#c33"] } results in the $colors variable being a just a color while this { "colors": ["#c33", "#c34"] } results in $colors being a list.

This can cause confusion eg. when iterating over a list of maps with @each as it will either pick the first element of the list or the first key-value pair in the first map depending on how many items the list has.

This PR adds support for one element lists by adding a trailing comma to all generated lists:

Comma-separated lists may have a trailing comma. This is especially useful because it allows you to represent a single-element list. For example, (1,) is a list containing 1 and (1 2 3,) is a comma-separated list containing a space-separated list containing 1, 2, and 3.

https://sass-lang.com/documentation/file.SASS_REFERENCE.html#lists

Copy link

@lizell lizell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like consistency!

@pmowrer
Copy link
Owner

pmowrer commented May 29, 2018

Great call @dentrado, sorry for the delay!

@pmowrer pmowrer merged commit 91c07d7 into pmowrer:master May 29, 2018
esr360 pushed a commit to One-Nexus/Synergy-Sass-Importer that referenced this pull request Jan 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants