From eda7856e486939a762315448eb3436ffb31e90fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Thu, 12 Nov 2026 11:25:30 +0100 Subject: [PATCH] fix: drop blank lines and split on any line break in nl2list --- src/Twig/AppRuntime.php | 3 ++- tests/Twig/Nl2ListTest.php | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 tests/Twig/Nl2ListTest.php diff --git a/src/Twig/AppRuntime.php b/src/Twig/AppRuntime.php index 203e71d..7cfad54 100644 --- a/src/Twig/AppRuntime.php +++ b/src/Twig/AppRuntime.php @@ -214,7 +214,8 @@ class AppRuntime implements RuntimeExtensionInterface return ''; } - $items = explode(PHP_EOL, $content); + // any line break, as textareas submit \r\n; blank lines (the default benefits end with one) are no items + $items = array_filter(array_map('trim', preg_split('/\R/', $content)), fn (string $item) => '' !== $item); $list = '