|
@@ -20,14 +20,19 @@ namespace Symfony\Framework\WebBundle\Util;
|
|
|
*/
|
|
|
class Mustache
|
|
|
{
|
|
|
- static public function renderFile($file, $parameters)
|
|
|
+ static public function renderString($string, $parameters)
|
|
|
{
|
|
|
$replacer = function ($match) use($parameters)
|
|
|
{
|
|
|
- return isset($parameters[$match[1]]) ? $parameters[$match[1]] : "{{ $match[0] }}";
|
|
|
+ return isset($parameters[$match[1]]) ? $parameters[$match[1]] : $match[0];
|
|
|
};
|
|
|
|
|
|
- file_put_contents($file, preg_replace_callback('/{{\s*(.+?)\s*}}/', $replacer, file_get_contents($file)));
|
|
|
+ return preg_replace_callback('/{{\s*(.+?)\s*}}/', $replacer, $string);
|
|
|
+ }
|
|
|
+
|
|
|
+ static public function renderFile($file, $parameters)
|
|
|
+ {
|
|
|
+ file_put_contents($file, static::renderString(file_get_contents($file), $parameters));
|
|
|
}
|
|
|
|
|
|
static public function renderDir($dir, $parameters)
|