[英]Ruby on Rails - how to make a clippy widget work from a helper file?
I have a app/helpers/application_helper.rb file with this code: 我有一个使用以下代码的app / helpers / application_helper.rb文件:
def clippy(text, bgcolor = "#ffffff")
text.gsub!('"',"'")
path_to_swf = "/flash/clippy/clippy.swf"
html = <<-EOF
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
width="110"
height="14"
id="clippy" >
<param name="movie" value="#{path_to_swf}"/>
<param name="allowScriptAccess" value="always" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param NAME="FlashVars" value="text=#{text}">
<param name="bgcolor" value="#{bgcolor}">
<embed src="#{path_to_swf}"
width="110"
height="14"
name="clippy"
quality="high"
allowScriptAccess="always"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer"
FlashVars="text=#{text}"
bgcolor="#{bgcolor}"
/>
</object>
EOF
raw(html)
end
and I am trying to use it in an HTML file (I use HAML so it is really a HAML file) but I am not sure what I need to do in order to actually call that code above and render the little clippy widget. 并且我正在尝试在HTML文件中使用它(我使用HAML,所以它实际上是HAML文件),但是我不确定要在上面实际调用该代码并呈现小片段小部件时需要做些什么。
I have this HAML code to try to render the clippy: 我有此HAML代码来尝试呈现短片:
.clippy-container=clippy("hello","#ffffff")
and I do that in a file located in app/views/my_file.html.haml 然后在app / views / my_file.html.haml中的文件中进行操作
Any idea what I need to do in order to make the clippy render? 任何想法,我需要做些什么才能使clippy渲染?
Thanks! 谢谢!
Isn't there a problem with 没问题吗
app/views/my_file.html.haml
Shouldn't it be 不是吗
app/views/some_controller/my_file.html.haml
I tried your code, it works fine! 我尝试了您的代码,效果很好!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.