// core related functionality which isn't available as the standalone
// component based serializer.
$frontMatter = FrontMatter::
create($source->
getCode(), Yaml::
class);
// Reconstruct the source if there is front matter data detected. Prepend
// the source with {% line \d+ %} to inform Twig that the source code
// actually starts on a different line past the front matter data. This is
// particularly useful when used in error reporting.
try { if (($line =
$frontMatter->
getLine()) > 1
) { $content = "{% line
$line %}" .
$frontMatter->
getContent();
$source =
new Source($content,
$source->
getName(),
$source->
getPath());
} } catch (FrontMatterParseException
$exception) { // Convert parse exception into a syntax exception for Twig and append
// the path/name of the source to help further identify where it occurred.
$message =
sprintf($exception->
getMessage() . ' in %s',
$source->
getPath() ?:
$source->
getName());
throw new SyntaxError($message,
$exception->
getSourceLine(),
$source,
$exception);
} return parent::
compileSource($source);
}