如何用凤凰渲染IMG?
我是凤凰城的新手。我需要在主页上向他们显示所有帖子和图片。我在我的索引模板中写了下面的代码:
< img src =“<%= blog.image.url({ @post.image,@post},signed:true)%>”>
我得到了此
lib/blog_web/templates/post/index.html.heex:19:21:预期关闭
“ for Attribute value
我缺少什么?
I'm new in phoenix. I need to display all the posts and pictures to them on the main page. I written below code in my index template:
<img src="<%= Blog.Image.url({@post.image, @post}, signed: true) %>">
And i got this
lib/blog_web/templates/post/index.html.heex:19:21: expected closing
"for attribute value
What i missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
取而代之的是,有特定的HEEX语法
attribute = {expression}
用于插值属性值。在您的示例中,您将使用引擎将正确插入引号和其他逃脱的引擎完全属性)。
The HEEx documentation notes:
Instead, there is specific HEEx syntax
attribute={expression}
for interpolating attribute values. In your example, you'd useThe engine will correctly insert quotation marks and other escaping as required (or, if
Blog.Image.url/2
returnsnil
, omit the attribute entirely).