belniakmedia/craft-excerptify

Provides the excerptify twig filter which truncates the provided variable's text or html to the nearest whole word based on the provided character length.

Installs: 2 426

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 2

Forks: 0

Open Issues: 0

Type:craft-plugin

2.0.0 2022-11-17 23:26 UTC

This package is auto-updated.

Last update: 2024-04-18 03:08:03 UTC


README

Provides the excertify twig filter which truncates the provided variable's text or html to the nearest whole word based on the provided character length.

Parameters

excerptify(int $characterCount, bool $forceBreakWord)
Parameter Type Default Description
$characterCount Int 200 Number of characters to limit result to.
$forceBreakWord Bool false When false, the text will be broken at the last occurring word break character. When true it will return the text up to the exact character limit, breaking a word if necessary.

Usage Examples

Break at nearest word

This is the default as in the same sas passing no arguments. Will return full words and the resulting string will not exceed 200 characters.

<p>{{ postContent | excerptify(200) }}</p>

To break exactly at the specified character count, even mid word, pass true for the forceBreakWord parameter:

<p>{{ postContent | excerptify(200, true) }}</p>

Brought to you by Belniak Media Inc.