|
@@ -67,8 +67,9 @@ class TemplatingExtension extends \Twig_Extension
|
|
|
public function getFunctions()
|
|
|
{
|
|
|
return array(
|
|
|
- 'url' => new \Twig_Function_Method($this, 'getUrl'),
|
|
|
- 'path' => new \Twig_Function_Method($this, 'getPath'),
|
|
|
+ 'url' => new \Twig_Function_Method($this, 'getUrl'),
|
|
|
+ 'path' => new \Twig_Function_Method($this, 'getPath'),
|
|
|
+ 'asset' => new \Twig_Function_Method($this, 'getAssetUrl'),
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -82,6 +83,11 @@ class TemplatingExtension extends \Twig_Extension
|
|
|
return $this->container->get('router')->generate($name, $parameters, true);
|
|
|
}
|
|
|
|
|
|
+ public function getAssetUrl($location)
|
|
|
+ {
|
|
|
+ return $this->container->get('templating.helper.assets')->getUrl($location);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Returns the token parser instance to add to the existing list.
|
|
|
*
|
|
@@ -102,9 +108,6 @@ class TemplatingExtension extends \Twig_Extension
|
|
|
// {% stylesheets %}
|
|
|
new HelperTokenParser('stylesheets', '', 'templating.helper.stylesheets', 'render'),
|
|
|
|
|
|
- // {% asset 'css/blog.css' %}
|
|
|
- new HelperTokenParser('asset', '<location>', 'templating.helper.assets', 'getUrl'),
|
|
|
-
|
|
|
// {% render 'BlogBundle:Post:list' with { 'limit': 2 }, { 'alt': 'BlogBundle:Post:error' } %}
|
|
|
new HelperTokenParser('render', '<template> [with <attributes:hash>[, <options:hash>]]', 'templating.helper.actions', 'render'),
|
|
|
|