Skip to content
This repository was archived by the owner on Nov 22, 2023. It is now read-only.
/ twig-inflect Public archive

🔤 Extension for the Twig templating language to transform the inflection of strings.

License

Notifications You must be signed in to change notification settings

craftplugins/twig-inflect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Important

This extension is no longer maintained.

TwigInflect

TwigInflect is a Twig extension to transform the inflection of strings.

The extension adds the following filters:

  • pluralize
  • singularize
  • camelize
  • dasherize
  • humanize
  • hyphenate
  • ordinalize
  • pascalize
  • titleize
  • underscore

Installation

{
    "require": {
        "joshuabaker/twig-inflect": "dev-master"
    }
}
<?php

use JoshuaBaker\Twig\Extensions\Extension\Inflect as TwigInflect;

$loader = new Twig_Loader_Filesystem('/path/to/templates');
$twig   = new Twig_Environment($loader);

// Registers extension
$twig->setExtensions(new TwigInflect);

Usage

{{ 'car' | pluralize }}
{{ 'car' | pluralize(3) }}
{# cars #}

{{ 'bikes' | pluralize(1) }}
{{ 'bikes' | singularize }}
{# bike #}

About

🔤 Extension for the Twig templating language to transform the inflection of strings.

Resources

License

Stars

Watchers

Forks

Languages