Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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 (116)
- 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)