Cutsom 输入格式,我做错了什么?

发布于 2024-09-16 09:44:27 字数 694 浏览 3 评论 0原文

我为 formtastic 制作了一种自定义输入法,它被设计为与 Carrierwave 一起使用,并且效果很好,但有一个例外,预览图像和其他 html 不会呈现,因为它正在被清理(我认为)。

我的处理方式完全错误吗?

这是代码:

def carrierwave_input(method, options)
   c = basic_input_helper(:file_field, :string, method, options) 

   c += hidden_input((method.to_s+"_cache").to_sym, {})


   if object.send("#{method.to_s}?")
     c += %{<img src="#{object.send("#{method.to_s}_url")}">}
     c += "<br>"
     c += boolean_input(("remove_"+method.to_s).to_sym, {})
   end

return c

end

call with:

form.input :thumb, :as => :carrierwave

渲染图像时,
标签被转义。

我该如何解决这个问题。

非常感谢

I have made a custom input method for formtastic, it is designed to work with carrierwave and it works great but with one exception, the preview image and other html will not render, as it is being sanitized (i think).

Am i going about this completely the wrong way?

Here is the code:

def carrierwave_input(method, options)
   c = basic_input_helper(:file_field, :string, method, options) 

   c += hidden_input((method.to_s+"_cache").to_sym, {})


   if object.send("#{method.to_s}?")
     c += %{<img src="#{object.send("#{method.to_s}_url")}">}
     c += "<br>"
     c += boolean_input(("remove_"+method.to_s).to_sym, {})
   end

return c

end

calling with:

form.input :thumb, :as => :carrierwave

when rendered the image and
tags escaped.

how can i get round this.

many thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谈情不如逗狗 2024-09-23 09:44:27

这是在 Rails 3 上吗?如果是这样,请尝试调用“return c.html_safe”

Is this on rails 3? If so, try calling "return c.html_safe"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文