简体   繁体   English

Twig媒体参考的语法略有不同会产生不同的结果-为什么?

[英]Slightly different syntax for Twig media reference yields different results — why?

I am working on a project that uses Twig and the Sonata Media Bundle. 我正在开发一个使用Twig和Sonata Media Bundle的项目。

In one part of my template, I have the following line: 在模板的一部分中,有以下一行:

<img src="{% path media, 'reference' %}" >

... and in that same Twig template, I have (inside of a logic block) this line of assignment: ...并且在相同的Twig模板中,(在逻辑块内)我有这行分配:

image: {src: path(media, 'reference'), alt:''}

... and while the fist line works, the second yields an error stating: ...并且在第一行工作的同时,第二行产生了一个错误,指出:

None of the chained routers were able to generate route: Route 'Story2_Ernährung_damals (1).jpg' not found 没有链接的路由器能够生成路由:找不到路由“Story2_Ernährung_damals(1).jpg”

What am I doing wrong here? 我在这里做错了什么?

It looks like I may have to write a Twig extension just to access the image url. 看来我可能不得不写一个Twig扩展名才能访问图像url。 Eeep! eep!

Sonata Media Bundle : acces media url Sonata Media Bundle:访问媒体URL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM