【发布时间】:2014-02-25 18:45:34
【问题描述】:
我正在尝试创建一个可以处理 2 个参数的特定树枝过滤器。
$documentURL = new Twig_SimpleFilter('documentURL', function($DocumentId, $UserId){
$URL = "http://example.example.com/start/".$DocumentId."/".$UserId."/";
return $URL;
});
并将过滤器添加到渲染中:
$twig->addFilter($documentURL);
现在在模板中请求过滤器:
{{documentURL(booking.docId, user.id)}}
但是,我收到该函数不存在的错误。很奇怪......因为它确实存在并且被包含在内。就像我的其他 15 个过滤器一样。
Fatal error: Uncaught exception 'Twig_Error_Syntax' with message 'The function "documentURL" does not exist in "profile.html" at line 78'
我是否以错误的方式请求过滤器? (可能是的......)
【问题讨论】:
标签: php symfony twig twig-filter