function evaluate($path, $options = array())
{
if (isset($options['data'])) {
$data = $options['data'];
} else {
if (!is_file($path)) {
throw new UnexpectedValueException("Asset {$path} not found");
}
$data = @file_get_contents($path);
}
$subContext = $this->createSubContext();
if (array_key_exists("processors", $options)) {
$processors = (array) $options["processors"];
} else {
$processors = array();
}
foreach ($processors as $p) {
$block = function () use(&$data) {
return $data;
};
if (is_callable($p)) {
$processor = $p($block);
} else {
$processor = new $p($block);
}
$subContext->path = $processor->source = $path;
$data = $processor->render($subContext);
}
$this->dependencyPaths = array_merge($this->dependencyPaths, $subContext->dependencyPaths);
$this->dependencyAssets = array_merge($this->dependencyAssets, $subContext->dependencyAssets);
return $data;
}