首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么这个image_tag不能工作?

为什么这个image_tag不能工作?
EN

Stack Overflow用户
提问于 2013-08-03 00:25:56
回答 1查看 392关注 0票数 0

我在试着让这件事起作用。

代码语言:javascript
复制
<%= image_tag('http://img.youtube.com/vi/<%= @video_tag %>/hqdefault.jpg') %>

它只适用于链接本身,但是显示它的image_tag会导致以下错误:

错误:

代码语言:javascript
复制
Showing /Users/maine/Downloads/leap_stage_v2/leap_stage_v2/app/views/songs/show.html.erb where line #19 raised:

/Users/maine/Downloads/leap_stage_v2/leap_stage_v2/app/views/songs/show.html.erb:19: syntax error, unexpected $undefined, expecting ')'
...er.safe_append='/hqdefault.jpg\') %>
...                               ^
/Users/maine/Downloads/leap_stage_v2/leap_stage_v2/app/views/songs/show.html.erb:68: syntax error, unexpected keyword_ensure, expecting ')'
/Users/maine/Downloads/leap_stage_v2/leap_stage_v2/app/views/songs/show.html.erb:70: syntax error, unexpected keyword_end, expecting ')'
Extracted source (around line #19):


   http://img.youtube.com/vi/<%= @video_tag %>/hqdefault.jpg

   <%= image_tag('http://img.youtube.com/vi/<%= @video_tag %>/hqdefault.jpg') %>


    <div class="videos">
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-08-03 00:29:28

不能嵌套<%标记。假设@video_tag是一个字符串,您可以执行以下操作以实现您想要的结果:

代码语言:javascript
复制
<%= image_tag("http://img.youtube.com/vi/#{@video_tag}/hqdefault.jpg") %>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18028021

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档