zenstruck/string-twig

Twig integration for zenstruck/string.

v2.0.0 2016-12-06 21:09 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..' #}