DEPRECATED: Since 1.0.3, JoliTypo provides built-in support for Symfony and Twig., (*1)
This bundle integrate the JoliTypo library into Symfony2., (*2)
Configuration
Add the Bundle to your Kernel:, (*3)
new Joli\TypoBundle\JoliTypoBundle(),
Define your Fixers preset as you want:, (*4)
joli_typo:
presets:
fr:
fixers: [ Ellipsis, Dimension, Dash, FrenchQuotes, FrenchNoBreakSpace, CurlyQuote, Trademark ]
locale: fr_FR
en:
fixers: [ Ellipsis, Dimension, Dash, EnglishQuotes, CurlyQuote, Trademark ]
locale: en_GB
Please refer to the JoliTypo documentation to learn more about fixers,
and how to combine them., (*5)
Note: there is no cache involved with JoliTypo, take care of it if you want to save some CPU cycles :grimacing:, (*6)
Twig function
The Bundle expose a new Twig function and filter named jolitypo
, waiting for two arguments: HTML content to fix and the preset name., (*7)
{{ jolitypo('
Hi folk!, (*8)
', 'fr') | raw }}
{# or #}
{{ '
Hi folk!, (*9)
' | jolitypo('fr') }}
Another way to use it is by passing a whole block to it:, (*10)
{% block content %}
{{ jolitypo(block('real_content'), 'fr') | raw }}
{% endblock %}
{% block real_content %}
My whole dynamic page
{% endblock %}
PHP Template helper
A jolitypo
helper is available in the view, exposing a fix
method:, (*11)
<?php echo $view['jolitypo']->fix('<p>Content</p>', 'en'); ?>
Todo
- Allow to set service as Fixer via an
@
- Use Lazy services for all the presets