Skip to content

Commit

Permalink
Merge pull request #1 from oddbird/string-split.draft-1.1
Browse files Browse the repository at this point in the history
[String Split] Draft 1.1
  • Loading branch information
dvdherron committed Nov 2, 2022
2 parents 17750ba + afab790 commit 114767e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
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.

0 comments on commit 114767e

Please sign in to comment.