Introduction

Wordsmith is a blazing fast, multi-byte safe, one-stop text manipulation toolkit for Craft CMS.

Features

Usage

All of Wordsmith’s methods are available in your Twig templates as inline filters, filter blocks, or functions.

INLINE FILTER
{{ 'Lorem ipsum.' | trim }}
FILTER BLOCK
{% filter trim %}
Lorem ipsum.
{% endfilter %}
FUNCTION
{{ trim('Lorem ipsum.') }}

As a best practice, I recommend using the inline filter and filter block style only for methods that return text. For methods that return a number, array object, or other non-string value, using the function synatx will probably feel most ‘correct’.

You should also use the named argument syntax for providing parameter values when needed.

For example, while you could technically invoke the chop method like this:

{{ text | chop(3, 'w') }}

…you should instead explicitly name the arguments, like this:

{{ text | chop(limit=3, unit='w') }}

By using this named argument syntax, you don’t need to supply all the possible parameters if you aren’t using them, and you’re guaranteed that your templates will keep working if the API changes.

For purposes of semantic versioning, the names of parameters are guaranteed to not change within a major version, but their order may.)

List of methods (abridged)

Requirements

License

Wordsmith is “Postcardware” — Open-source and free to use… And if it helps you out, please send me a digital ‘postcard’ and let me know how you’re using it.

Support

Wordsmith is free and community-supported.

If you’d like to report a bug or make improvements/contributions to the code, please open a GitHub Issue or submit a Pull Request to the dev branch.

If you’d like to request implementation support or commission a customization for your project, please email Support.

Thanks

Thanks for using Wordsmith!