/**
* validate partial
*
* @param array<string,array|string|integer> $context current compile context
* @param array<boolean|integer|string|array> $vars parsed arguments list
*
* @return integer|boolean Return 1 or larger number for runtime partial, return true for other case
*/
protected static function partial(&$context, $vars)
{
if (Parser::isSubExp($vars[0])) {
if ($context['flags']['runpart']) {
return $context['usedFeature']['dynpartial']++;
} else {
$context['error'][] = "You use dynamic partial name as '{$vars[0][2]}', this only works with option FLAG_RUNTIMEPARTIAL enabled";
return true;
}
} else {
if ($context['currentToken'][Token::POS_OP] !== '#>') {
Partial::read($context, $vars[0][0]);
}
}
if (!$context['flags']['runpart']) {
$named = count(array_diff_key($vars, array_keys(array_keys($vars)))) > 0;
if ($named || count($vars) > 1) {
$context['error'][] = "Do not support {{>{$context['currentToken'][Token::POS_INNERTAG]}}}, you should do compile with LightnCandy::FLAG_RUNTIMEPARTIAL flag";
}
}
return true;
}