| 1 | <?php |
||
| 14 | class Mustache |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @param string $string |
||
| 18 | * @param array $parameters |
||
| 19 | * |
||
| 20 | * @return mixed |
||
| 21 | */ |
||
| 22 | public static function replace($string, array $parameters) |
||
| 23 | { |
||
| 24 | $replacer = function ($match) use ($parameters) { |
||
| 25 | return isset($parameters[$match[1]]) ? $parameters[$match[1]] : $match[0]; |
||
| 26 | }; |
||
| 27 | |||
| 28 | return preg_replace_callback('/{{\s*(.+?)\s*}}/', $replacer, $string); |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @param string $file |
||
| 33 | * @param array $parameters |
||
| 34 | * |
||
| 35 | * @return mixed |
||
| 36 | */ |
||
| 37 | public static function replaceFromFile($file, array $parameters) |
||
| 41 | } |
||
| 42 |