zenstruck/string-twig

This package is abandoned and no longer maintained. The author suggests using the zenstruck/string package instead.

Twig integration for zenstruck/string.

v2.0.0 2016-12-06 21:09 UTC

This package is auto-updated.

Last update: 2020-10-28 14:23:45 UTC


README

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version License

Twig integration for zenstruck/string.

Installation

composer require zenstruck/string-twig

Manual Setup

See the Twig documentation for more information

use Zenstruck\String\Bridge\Twig\StringExtension;

$twig->addExtension(new StringExtension());

Add to a Symfony Project

Add to your config.yml:

services:
    zenstruck.string.twig_extension:
        class: Zenstruck\String\Bridge\Twig\StringExtension
        public: false
        tags:
            - { name: twig.extension }

Usage

For full function documentation, see zenstruck\string.

{{ remove_whitespace('  foo   bar') }} {# 'foo bar' #}

{{ null_trim('   ') }} {# null #}

{{ truncate_word('      foo       bar  baz', 10) }} {# 'foo bar..' #}