Skip to content
twig extensions for text (limit text, remove accents)
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/Ec/Twig
tests/Ec/Twig
.gitignore
LICENSE
README.md
composer.json
phpunit.xml

README.md

TwigTextExtensions

Twig extension with some common text manipulations filters. See examples below

services:
  twig.extension.ec.text:
    class: Ec\Twig\TextExtension
    tags:
      - { name: twig.extension }
{{ "one two three" | limit({'maxWords': 2, 'continue': '...'}) }}   <!-- one two... -->
{{ "Téxt wìth Åççéñts" | remove_accents }}                          <!-- Text with Accents -->
{{ Very Random "string" !! | urlify }}                              <!-- very-random-string -->
{{ 1000.2, | money_format }}                                        <!-- 1,000.20  -->
{{ http://www.amazon.com/1/a/bc | get_host_without_www }}           <!--  amazon.com -->
{{ $person | item_to_array }}                                       <!-- ['name'=>'John', 'surname'=>'White'] -->
{{ [$person1, $person2] | properties('name') }}                     <!-- ['John', 'Peter'] -->
{{ 3 | ordinal }}                                                   <!-- 3rd -->
{{ includeRaw(/path/to/file }}                                     <!-- content from the file -->

See the unit test for more examples.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.