mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-21 07:37:43 +00:00
added a way to add token parsers, filters, and visitors without creating an extension
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
Backward incompatibilities:
|
||||
* The short notation of the `block` tag changed.
|
||||
|
||||
* added a way to add token parsers, filters, and visitors without creating an extension
|
||||
* added three interfaces: Twig_NodeInterface, Twig_TokenParserInterface, and Twig_FilterInterface
|
||||
* changed the generated code to match the new coding standards
|
||||
* fixed sandbox mode (__toString() method check was not enforced if called implicitly from a simple statement like {{ article }})
|
||||
|
||||
@@ -323,6 +323,15 @@ class Twig_Environment
|
||||
return $this->extensions;
|
||||
}
|
||||
|
||||
public function addTokenParser(Twig_TokenParserInterface $parser)
|
||||
{
|
||||
if (null === $this->parsers) {
|
||||
$this->getTokenParsers();
|
||||
}
|
||||
|
||||
$this->parsers[] = $parser;
|
||||
}
|
||||
|
||||
public function getTokenParsers()
|
||||
{
|
||||
if (null === $this->parsers) {
|
||||
@@ -335,6 +344,15 @@ class Twig_Environment
|
||||
return $this->parsers;
|
||||
}
|
||||
|
||||
public function addNodeVisitor(Twig_NodeVisitorInterface $visitor)
|
||||
{
|
||||
if (null === $this->visitors) {
|
||||
$this->getNodeVisitors();
|
||||
}
|
||||
|
||||
$this->visitors[] = $visitor;
|
||||
}
|
||||
|
||||
public function getNodeVisitors()
|
||||
{
|
||||
if (null === $this->visitors) {
|
||||
@@ -347,6 +365,15 @@ class Twig_Environment
|
||||
return $this->visitors;
|
||||
}
|
||||
|
||||
public function addFilter($name, Twig_NodeFilter $filter)
|
||||
{
|
||||
if (null === $this->filters) {
|
||||
$this->getFilters();
|
||||
}
|
||||
|
||||
$this->filters[$name] = $filter;
|
||||
}
|
||||
|
||||
public function getFilters()
|
||||
{
|
||||
if (null === $this->filters) {
|
||||
|
||||
Reference in New Issue
Block a user