From e4b126976d39235cc0a239fc524f5f462c1cf420 Mon Sep 17 00:00:00 2001
From: Cathy Sarisky <42299862+cathysarisky@users.noreply.github.com>
Date: Sat, 8 Nov 2025 11:48:59 -0500
Subject: [PATCH] Refactor split helper documentation for clarity
Updated the usage syntax for the split helper from `{{split}}` to `{{#split}}` and added additional examples for clarity, clarifying the behavior for empty strings.
---
themes/helpers/utility/split.mdx | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/themes/helpers/utility/split.mdx b/themes/helpers/utility/split.mdx
index ae25c8b..2a356a9 100644
--- a/themes/helpers/utility/split.mdx
+++ b/themes/helpers/utility/split.mdx
@@ -1,13 +1,13 @@
---
title: "split"
-description: 'Usage: `{{split "apple-banana-pear" separator="-"}}`'
+description: 'Usage: `{{#split "apple-banana-pear" separator="-"}}`'
---
***
-The `{{split}}` helper is designed to split a string into separate strings. It can be used in block or inline mode.
+The `{{#split}}` helper is designed to split a string into separate strings. It can be used in block or inline mode.
-The `{{split}}` helper returns an array, suitable for iteration with `{{#foreach}}`, with individual elements of the array suitable for any helper that expects a string.
+The `{{#split}}` helper returns an array, suitable for iteration with `{{#foreach}}`, with individual elements of the array suitable for any helper that expects a string.
Individual elements of the array may be addressed as `{{this}}` within a `{{#foreach}}` loop.
@@ -25,7 +25,7 @@ Outputs:
|hello||world|
```
-
+### Inline mode:
```handlebars
{{#foreach (split "hello, world" separator=",")}}
{{this}} {{#unless @last}}
{{/unless}}
@@ -38,6 +38,7 @@ hello
world
`{{split}}` is designed for strings. If it receives a non-string, it attempts to convert it to a string first.
+
## The separator attribute
By default, strings are split at each ",". The `separator=""` attribute allows settings the split location to an arbitrary value.
@@ -46,6 +47,7 @@ Passing an empty string for the separator results in splitting to single charact
Separators may be multiple characters.
+
### Additional examples
```handlebars
@@ -78,3 +80,20 @@ from-my-slug
{{/foreach}}
```
+
+### No empty strings
+Split filters the array to exclude any empty strings from the final result. Sequential separators will not result in empty strings.
+
+```handlebars
+{{#foreach (split ",banana,,apple,")}}
+ {{#unless @first}}{{#unless @last}}-{{/unless}}{{/unless}}{{#unless @last}}
+ ({{this}})
+ {{/unless}}
+{{/foreach}}
+
+Outputs:
+
+(banana)(apple)
+
+Not: ()(banana)()(apple)()
+```