public static function Typogrify::filter in Typogrify 8
Same name in this branch
- 8 src/Typogrify.php \Drupal\typogrify\Typogrify::filter()
- 8 src/TwigExtension/Typogrify.php \Drupal\typogrify\TwigExtension\Typogrify::filter()
Filter text by Typogrify.
Parameters
string $text: The text to be processed.
string[] $options: Filters to be used for filtering. If empty, all filters will be used. Possible values: amp, widont, smartypants, caps, initial_quotes, dash.
Return value
string The filtered string.
File
- src/TwigExtension/ Typogrify.php, line 37 
Class
- Typogrify
- A class providing Drupal Twig extensions.
Namespace
Drupal\typogrify\TwigExtensionCode
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;
}