开发者

How can I insert a ruby form into Redcloth-modified HTML in Rails?

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 some开发者_如何学JAVAwhere 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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜