Skip to content

nizur/Truncate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 

Repository files navigation

Truncate

A simple Craft CMS plugin/Twig filter.

Usage

{{ entry.body | truncate('words', '150', '...', true) }}

Params

  • Unit: words or chars. Defaults to chars.
  • Limit: Defaults to 150.
  • Ending: Defaults to an empty string.
  • StripHTML: Removes all HTML tags. Defaults to false

Note

The native Twig filters split, join, and slice can be used to achieve a similar result:

{% set words = "these are words"|split(" ")|slice(1, 2)|join(" ") %}
{{ words }}

About

A simple Craft CMS plugin/Twig filter.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages