我正在尝试创建一个可以处理 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'
我是否以错误的方式请求过滤器?(大概是...)