Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Symfony在翻译内容中添加路径链接_Symfony_Twig - Fatal编程技术网

使用Symfony在翻译内容中添加路径链接

使用Symfony在翻译内容中添加路径链接,symfony,twig,Symfony,Twig,对于我的lage信息页面,内容由翻译xlf文件作为原始文本生成 以下是xlf文件的一部分: <target><![CDATA[Click <a href="{{ path('_homepage') }}">here</a> to go to the homepage]]></target> 只有主页的路径url不起作用,因为它是作为文本放置的?单独添加链接,例如: 最好在控制器中使用str_替换转换占位符,还是将链接作为变量发送到t

对于我的lage信息页面,内容由翻译xlf文件作为原始文本生成

以下是xlf文件的一部分:

<target><![CDATA[Click <a href="{{ path('_homepage') }}">here</a> to go to the homepage]]></target>

只有主页的路径url不起作用,因为它是作为文本放置的?

单独添加链接,例如:



最好在控制器中使用str_替换转换占位符,还是将链接作为变量发送到twig并将占位符转换为%link%占位符?无需使用str_替换-只需注入转换服务,让它尽其所能。
{{ content|raw|nl2br }}