🔤 Twig extension for Case Converter
This Twig extension is port from jawira/case-converter.
Usage
This library provides the following filters:
from_ | to_ |
---|---|
from_auto |
|
from_ada |
to_ada |
from_camel |
to_camel |
from_cobol |
to_cobol |
from_dot |
to_dot |
from_kebab |
to_kebab |
from_lower |
to_lower |
from_macro |
to_macro |
from_pascal |
to_pascal |
from_sentence |
to_sentence |
from_snake |
to_snake |
from_title |
to_title |
from_train |
to_train |
from_uppder |
to_upper |
Use a to_*
filter to automatically change the
casing convention of a string:
{{ 'welcome-to-the-jungle'|to_camel }}
{# outputs 'welcomeToTheJungle' #}
Optionally, you can call a from_*
filter to specify the casing convention of input string:
{{ 'user.first-name'|from_dot|to_upper }}
{# outputs 'USER FIRST-NAME' #}
How to install
Install with Composer:
$ composer require jawira/case-converter-twig
If you are not using Symfony Flex, you also have to register the extension:
# config/packages/case_converter_twig.yaml
services:
jawira.case.converter.twig:
class: \Jawira\CaseConverterTwig\CaseConverterExtension
tags: [ 'twig.extension' ]
Contributing
If you liked this project, ⭐ star it on GitHub.
License
This library is licensed under the MIT license.
Packages from jawira
-
jawira/case-converter
- Convert strings between 13 naming conventions: Snake case, Camel case, Pascal case, Kebab case, Ada case, Train case, Cobol case, Macro case, Upper case, Lower case, Sentence case, Title case and Dot notation.
-
jawira/emoji-catalog
- Get access to +3000 emojis as class constants.
- more...