Skip to content
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

[String Split] Draft 1.1 #1

Merged
merged 2 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions accepted/string-split.changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Draft 1.1

* Returns a bracketed list instead of an unbracketed one to be more clear
about what type of value is being returned.

## Draft 1

* Initial draft.
12 changes: 6 additions & 6 deletions accepted/string-split.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `string.split()`: Draft 1
# `string.split()`: Draft 1.1

*([Issue](https://github.com/sass/sass/issues/1950))*

Expand Down Expand Up @@ -26,7 +26,7 @@ their own versions of functions that achieve this functionality.
This proposal adds the `string.split()` function to the `sass:string` module.
The function takes a string, splits it based on a provided separator, and
returns an unbracketed, comma-separated list of substrings.
returns a bracketed, comma-separated list of substrings.

This could be used to take a string and repurpose parts of it for some other
use. For example, fonts contained in a font stack list could be split into
Expand All @@ -36,22 +36,22 @@ Examples:

```scss
$fonts: "Helvetica Neue, Helvetica, Arial";
string.split($fonts, ', '); // "Helvetica Neue", "Helvetica", "Arial"
string.split($fonts, ', '); // ["Helvetica Neue", "Helvetica", "Arial"]
```

A third argument can set a limit to the the number of splits performed on the
string:

```scss
string.split($fonts, ', ', 1); // "Helvetica Neue", "Helvetica, Arial"
string.split($fonts, ', ', 1); // ["Helvetica Neue", "Helvetica, Arial"]
```


An empty `$separator` returns all Unicode code points in the original string:

```scss
$font: "Helvetica"
string.split($font, ''); // "H", "e", "l", "v", "e", "t", "i", "c", "a"
string.split($font, ''); // ["H", "e", "l", "v", "e", "t", "i", "c", "a"]
```


Expand Down Expand Up @@ -123,4 +123,4 @@ split($string, $separator, $limit: null)

* Increase `split-counter` by 1.

* Return `split-list` as an unbracketed, comma-separated list.
* Return `split-list` as a bracketed, comma-separated list.