/** * Expand partial string recursively. * * @param string $template template string * * @param mixed $context * * @return string expanded template * * @expect "123\n" when input '{{> test1}}', Array('basedir' => Array('tests'), 'usedFeature' => Array('partial' =>0), 'fileext' => Array('.tmpl')) * @expect "a123\nb\n" when input '{{> test2}}', Array('basedir' => Array('tests'), 'usedFeature' => Array('partial' =>0), 'fileext' => Array('.tmpl')) */ public static function expandPartial($template, &$context) { $template = preg_replace_callback(self::PARTIAL_SEARCH, function ($matches) use(&$context) { return LightnCandy::expandPartial(LightnCandy::readPartial($matches[1], $context), $context); }, $template); return $template; }