Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/parisek/twig-typography
Uses PHP-Typography library and exposes it as Twig Extension.
https://github.com/parisek/twig-typography
php twig twig-extension typography
Last synced: 2 months ago
JSON representation
Uses PHP-Typography library and exposes it as Twig Extension.
- Host: GitHub
- URL: https://github.com/parisek/twig-typography
- Owner: parisek
- License: gpl-2.0
- Created: 2021-03-02T22:58:03.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-10T08:41:39.000Z (3 months ago)
- Last Synced: 2024-10-10T10:29:38.746Z (3 months ago)
- Topics: php, twig, twig-extension, typography
- Language: PHP
- Homepage: https://packagist.org/packages/parisek/twig-typography
- Size: 15.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
Twig Typography Extension
=======================
Uses [PHP-Typography](https://github.com/mundschenk-at/php-typography) library and exposes it as Twig Extension. See [class-settings.php](https://github.com/mundschenk-at/php-typography/blob/0fa6cf412124171360eebab59ca77769c67c9740/src/class-settings.php#L247) for possible options.* Hyphenation — over 50 languages supported
* Space control, including:
- widow protection
- gluing values to units
- forced internal wrapping of long URLs & email addresses
* Intelligent character replacement, including smart handling of:
- quote marks (‘single’, “double”)
- dashes ( – )
- ellipses (…)
- trademarks, copyright & service marks (™ ©)
- math symbols (5×5×5=53)
- fractions (1⁄16)
- ordinal suffixes (1st, 2nd)
* CSS hooks for styling:
- ampersands,
- uppercase words,
- numbers,
- initial quotes & guillemets.## Installation
Twig Typography Extension can be easily installed using [composer](http://getcomposer.org/)
composer require parisek/twig-typography
## Usage
```php
$twig = new Twig_Environment($loader);
$twig->addExtension(new Parisek\Twig\TypographyExtension(__DIR__ . '/typography.yml'));
```## Template
```twig
{{ title|typography }}
``````twig
{{ "Lorem Ipsum"|typography }}
``````twig
{{ title|typography({'set_dewidow': FALSE}) }}
``````twig
{% typography %}
Lorem Ipsum
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce ullamcorper semper nunc, a hendrerit leo auctor ultricies.
{% endtypography %}
```## Inspiration
- [Twig Extension Symfony Bundle](https://github.com/debach/typography-bundle)
- [Twig Typography Drupal Module](https://www.drupal.org/project/twig_typography)