mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
Remove {unser} and add tests
This commit is contained in:
@ -17,7 +17,7 @@ use Fenom\Template;
|
||||
*/
|
||||
class Fenom
|
||||
{
|
||||
const VERSION = '1.3';
|
||||
const VERSION = '1.4';
|
||||
|
||||
/* Actions */
|
||||
const INLINE_COMPILER = 1;
|
||||
@ -246,10 +246,6 @@ class Fenom
|
||||
'type' => self::BLOCK_COMPILER,
|
||||
'open' => 'Fenom\Compiler::autoescapeOpen',
|
||||
'close' => 'Fenom\Compiler::autoescapeClose'
|
||||
),
|
||||
'unset' => array(
|
||||
'type' => self::INLINE_COMPILER,
|
||||
'parser' => 'Fenom\Compiler::tagUnset'
|
||||
)
|
||||
);
|
||||
|
||||
@ -540,17 +536,6 @@ class Fenom
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $function
|
||||
* @param Fenom\Template $template
|
||||
* @return bool|string
|
||||
* @deprecated
|
||||
*/
|
||||
public function getFunction($function, Template $template = null)
|
||||
{
|
||||
return $this->getTag($function, $template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns tag info
|
||||
*
|
||||
|
@ -1028,23 +1028,4 @@ class Compiler
|
||||
$scope->tpl->escape = $scope["escape"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset present variables
|
||||
*
|
||||
* @param Tokenizer $tokens
|
||||
* @param Template $tpl
|
||||
* @return string
|
||||
* @throws InvalidUsageException
|
||||
*/
|
||||
public static function tagUnset(Tokenizer $tokens, Template $tpl)
|
||||
{
|
||||
$vars = array();
|
||||
while ($tokens->valid()) {
|
||||
$vars[] = $tpl->parseVariable($tokens);
|
||||
}
|
||||
if (!$vars) {
|
||||
throw new InvalidUsageException("Unset must accept variable(s)");
|
||||
}
|
||||
return 'unset(' . implode(', ', $vars) . ')';
|
||||
}
|
||||
}
|
||||
|
@ -25,10 +25,6 @@ class UnexpectedTokenException extends \RuntimeException
|
||||
}
|
||||
if (!$tokens->curr) {
|
||||
$this->message = "Unexpected end of " . ($where ? : "expression") . "$expect";
|
||||
} elseif ($tokens->curr[0] === T_WHITESPACE) {
|
||||
$this->message = "Unexpected whitespace$expect";
|
||||
} elseif ($tokens->curr[0] === T_BAD_CHARACTER) {
|
||||
$this->message = "Unexpected bad characters (below ASCII 32 except \\t, \\n and \\r) in " . ($where ? : "expression") . "$expect";
|
||||
} else {
|
||||
$this->message = "Unexpected token '" . $tokens->current() . "' in " . ($where ? : "expression") . "$expect";
|
||||
}
|
||||
|
@ -304,26 +304,6 @@ class Tokenizer
|
||||
return $this->next ? $this->next[1] == $token : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return substring. This method doesn't move pointer.
|
||||
* @param int $offset
|
||||
* @param int $limit
|
||||
* @return string
|
||||
*/
|
||||
public function getSubstr($offset, $limit = 0)
|
||||
{
|
||||
$str = '';
|
||||
if (!$limit) {
|
||||
$limit = $this->_max;
|
||||
} else {
|
||||
$limit += $offset;
|
||||
}
|
||||
for ($i = $offset; $i <= $limit; $i++) {
|
||||
$str .= $this->tokens[$i][1] . $this->tokens[$i][2];
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return token and move pointer
|
||||
* @return mixed
|
||||
|
Reference in New Issue
Block a user