Move Twig link filter and url_param and form_param functions to PicoTwigExtension
This commit is contained in:
parent
1f35346f53
commit
46f5d3d56d
@ -1500,11 +1500,6 @@ class Pico
|
|||||||
$this->twig->addExtension(new Twig_Extension_Debug());
|
$this->twig->addExtension(new Twig_Extension_Debug());
|
||||||
$this->twig->addExtension(new PicoTwigExtension($this));
|
$this->twig->addExtension(new PicoTwigExtension($this));
|
||||||
|
|
||||||
// register link filter and the url_param and form_param functions
|
|
||||||
$this->twig->addFilter(new Twig_SimpleFilter('link', array($this, 'getPageUrl')));
|
|
||||||
$this->twig->addFunction(new Twig_SimpleFunction('url_param', array($this, 'getUrlParameter')));
|
|
||||||
$this->twig->addFunction(new Twig_SimpleFunction('form_param', array($this, 'getFormParameter')));
|
|
||||||
|
|
||||||
// register content filter
|
// register content filter
|
||||||
// we pass the $pages array by reference to prevent multiple parser runs for the same page
|
// we pass the $pages array by reference to prevent multiple parser runs for the same page
|
||||||
// this is the reason why we can't register this filter as part of PicoTwigExtension
|
// this is the reason why we can't register this filter as part of PicoTwigExtension
|
||||||
|
@ -51,7 +51,7 @@ class PicoTwigExtension extends Twig_Extension
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Twig filters markdown, map and sort_by
|
* Returns a list of Pico-specific Twig filters
|
||||||
*
|
*
|
||||||
* @see Twig_ExtensionInterface::getFilters()
|
* @see Twig_ExtensionInterface::getFilters()
|
||||||
* @return Twig_SimpleFilter[] array of Pico's Twig filters
|
* @return Twig_SimpleFilter[] array of Pico's Twig filters
|
||||||
@ -62,6 +62,21 @@ class PicoTwigExtension extends Twig_Extension
|
|||||||
'markdown' => new Twig_SimpleFilter('markdown', array($this, 'markdownFilter')),
|
'markdown' => new Twig_SimpleFilter('markdown', array($this, 'markdownFilter')),
|
||||||
'map' => new Twig_SimpleFilter('map', array($this, 'mapFilter')),
|
'map' => new Twig_SimpleFilter('map', array($this, 'mapFilter')),
|
||||||
'sort_by' => new Twig_SimpleFilter('sort_by', array($this, 'sortByFilter')),
|
'sort_by' => new Twig_SimpleFilter('sort_by', array($this, 'sortByFilter')),
|
||||||
|
'link' => new Twig_SimpleFilter('link', array($this->pico, 'getPageUrl'))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of Pico-specific Twig functions
|
||||||
|
*
|
||||||
|
* @see Twig_ExtensionInterface::getFunctions()
|
||||||
|
* @return Twig_SimpleFunction[] array of Pico's Twig functions
|
||||||
|
*/
|
||||||
|
public function getFunctions()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'url_param' => new Twig_SimpleFunction('url_param', array($this->pico, 'getUrlParameter')),
|
||||||
|
'form_param' => new Twig_SimpleFunction('form_param', array($this->pico, 'getFormParameter'))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user