From e8ced9c4063fe8b95460bd02e72e4430465eb142 Mon Sep 17 00:00:00 2001 From: Stefan Hanauska Date: Mon, 13 Jan 2025 07:18:41 +0100 Subject: [PATCH] Support shortentext helper --- mustache_lint/mustache_lint.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mustache_lint/mustache_lint.php b/mustache_lint/mustache_lint.php index 3e324b65..daa8cedb 100644 --- a/mustache_lint/mustache_lint.php +++ b/mustache_lint/mustache_lint.php @@ -117,6 +117,12 @@ $content = preg_replace('([{}]{2,3})', '{{=<% %>=}}${0}<%={{ }}=%>', $content); return '"' . $content . '"'; }, + 'shortentext' => function ($text) { + [$length, $content] = explode(',', $text, 2); + $length = intval(trim($length)); + $content = trim($content); + return substr($content, 0, $length) . (strlen($content > $length) ? '...' : ''); + }, 'js' => [$jshelper, 'add_js'], ], 'partials_loader' => new simple_core_component_mustache_loader($theme),