Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Commit

Permalink
Merge pull request #56 from fourkitchens/feature/t
Browse files Browse the repository at this point in the history
Add a better t filter to pattern lab so it plays well with Drupal
  • Loading branch information
ccjjmartin committed Apr 25, 2017
2 parents ad81106 + 80be8e3 commit dd2fe04
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions components/_twig-components/filters/t.filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
* Bring Drupal filters in just so Pattern Lab doesn't bork.
*/

$filter = new Twig_SimpleFilter('t', function ($string) {
return $string;
$filter = new Twig_SimpleFilter('t', function ($string, $array = array()) {
if (is_string($string) && is_array($array)) {
$haystack = $string;
foreach ($array as $needle => $replace) {
$haystack = str_replace($needle, $replace, $haystack);
}
return $haystack;
}
});

0 comments on commit dd2fe04

Please sign in to comment.