如何将 ruby 表单插入到 Rails 中 Redcloth 修改的 HTML 中?
我有一个页面,我使用 RedCloth 对文本和图像使用 markdown。我希望能够通过放置字符串 [Form] 将表单放置在文本中的某个位置,并且我的应用程序会进行替换,将 [Form] 替换为 ruby 代码以执行 Rails 表单。
我该怎么做?我目前使用“<%=h %>”执行 RedCloth 编辑的文本所以我不知道如何用 Rails 表单代码替换字符串?
谢谢!
例如,在我看来,我当前使用 gem 及其助手显示 mp3 播放器:
5 #landing_page
6 #message
7 = mp3_player @landing_page.mp3.url unless @landing_page.mp3_file_name.blank?
8 = @redcloth_landing_page
但实际上我希望能够通过使用替换字符串 {mp3} 将此 mp3 播放器放置在 redcloth 文档中的某处,从而具有更大的灵活性。
我希望 {mp3} 的放置位置就是 mp3 播放器显示的位置。
I have a page where I use RedCloth to use markdown for the text and images. I want to be able to place a form somewhere in the text by putting the string [Form] and my application does a substitution to replace [Form] with the ruby code to execute a Rails form.
How do I do this? I currently executve the RedCloth-ed text with a "<%=h %>" so I don't know how to substitute a string with the Rails form code?
Thanks!
For example, in my view, I currently display a mp3 player using a gem and its helper:
5 #landing_page
6 #message
7 = mp3_player @landing_page.mp3.url unless @landing_page.mp3_file_name.blank?
8 = @redcloth_landing_page
But I actually want more flexibility in terms of being able to place this mp3 player somewhere within the redcloth document by using a substitution string {mp3}.
I'd like where the {mp3} is placed to be where the mp3 player shows up.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,我认为我正确理解了你的问题:D,
如果你想添加一个表单(带有 html 标签)作为字符串并希望将其作为普通表单使用,你应该查看像“liquid”这样的模板语言(https: //github.com/tobi/liquid/)。它也适用于“RedCloth”,为
欢呼
Sameera
First of all I think i understood your question correctly :D,
If you want to add a form (with html tags) as string and wish to function it as a normal form you should look in to template language like 'liquid' (https://github.com/tobi/liquid/). and it works with 'RedCloth' too
cheers
sameera