【发布时间】:2021-05-05 13:11:07
【问题描述】:
使用 Rails 6 / Ruby 6:
我正在尝试将图像路径插入 SVG 图像标签,但不知何故路径斜线被剥离了。
<% imgpath = asset_path(challenge.imgname) %>
<%= logger.debug "Asset: " + imgpath %>
输出预期:
Asset: /assets/shower.jpg
但在我的 SVG 图像标签内:
<image "<%= asset_path challenge.imgname %>" height="100%" width="100%" preserveAspectRatio="xMidYMid slice" />
(以及在 Chrome 中“检查”时) 它显示为:
<image " assets shower.jpg " height="100%" width="100%"
preserveAspectRatio="xMidYMid slice"></image>
使用raw 似乎并没有改变这种行为。
Chrome 中神秘的“查看源代码”确实显示了路径:
<image "/assets/greencommute.jpg" height="100%" width="100%" preserveAspectRatio="xMidYMid slice" />
但不管图像不渲染。
关于发生了什么的任何线索?
提前致谢。
【问题讨论】:
标签: ruby-on-rails ruby svg