Created
January 3, 2019 13:03
-
-
Save samhernandez/8608b1887471484777155e4435f971d4 to your computer and use it in GitHub Desktop.
Twig text truncation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# limit to 300 characters, then 40 words, and remove last word which is likely cut off #} | |
{{ content | slice(0, 300) | split(' ') | slice(0, 40) | slice(0, -1) | join(' ') | raw }}… |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment