Skip to content
Brought to you by Allons-y Studio
dashly A standard library of filters, transforms, & shortcodes for Eleventy

strings

In Filters

String-manipulation filters for Eleventy.

import {
	firstWord,
	lastWord,
	trim,
	stripWhitespace,
	digitsOnly,
	capitalize,
	title,
} from '@allons-y/dashly/filters/strings';

firstWord(value)

Return the first whitespace-delimited word of a string.

Parameters

Name Type Default Description
value string

Returns

string | undefined

lastWord(value)

Return the last whitespace-delimited word of a string.

Parameters

Name Type Default Description
value string

Returns

string | undefined

trim(value)

Trim leading and trailing whitespace.

Parameters

Name Type Default Description
value string

Returns

string | undefined

stripWhitespace(value)

Remove all whitespace characters from a string.

Parameters

Name Type Default Description
value string

Returns

string | undefined

digitsOnly(value)

Strip every non-digit character from a string. Useful for phone-number normalization before formatting.

Parameters

Name Type Default Description
value string

Returns

string | undefined

capitalize(value)

Uppercase the first character of a string and lowercase the rest. Matches the semantics of Nunjucks/Liquid capitalize.

Parameters

Name Type Default Description
value string

Returns

string | undefined

Examples

// 'Hello world'
capitalize('hello WORLD');
{{ heading | capitalize }}

title(value)

Title-case a string by uppercasing the first letter of each whitespace- delimited word and lowercasing the rest. Useful for converting slugs or raw labels into display headings.

Parameters

Name Type Default Description
value string

Returns

string | undefined

Examples

// 'The Quick Brown Fox'
title('the QUICK brown fox');
{{ tag | title }}

Allons-y Studio

Let's build something great together

A front-end & design systems studio helping teams ship consistent, accessible UI faster.