Typogrify.php in Typogrify 8
File
src/TwigExtension/Typogrify.php
View source
<?php
namespace Drupal\typogrify\TwigExtension;
use Drupal\typogrify\SmartyPants;
use Drupal\typogrify\Typogrify as TypogrifyBase;
class Typogrify extends \Twig_Extension {
public function getFilters() {
return [
new \Twig_SimpleFilter('typogrify', [
$this,
'filter',
], [
'is_safe' => [
'html',
],
]),
];
}
public static function filter($text, array $options = []) {
if (empty($options)) {
return TypogrifyBase::filter($text);
}
if (in_array('amp', $options)) {
$text = TypogrifyBase::amp($text);
}
if (in_array('widont', $options)) {
$text = TypogrifyBase::widont($text);
}
if (in_array('smartypants', $options)) {
$text = SmartyPants::process($text);
}
if (in_array('caps', $options)) {
$text = TypogrifyBase::caps($text);
}
if (in_array('initial_quotes', $options)) {
$text = TypogrifyBase::initialQuotes($text);
}
if (in_array('dash', $options)) {
$text = TypogrifyBase::dash($text);
}
return $text;
}
}
Classes
Name |
Description |
Typogrify |
A class providing Drupal Twig extensions. |