开发者

Handling more than one markup language in a text area

开发者 https://www.devze.com 2023-02-03 03:27 出处:网络
I\'d like to now how to handle multiple markup languages (textile, markdown and bbcode) in a text area using ruby on rails 3.

I'd like to now how to handle multiple markup languages (textile, markdown and bbcode) in a text area using ruby on rails 3.

The user would be able to select the markup language he/she wants to use, write in that language, and then the view would render the text 开发者_如何学运维using the markup language selected by the user.

I'm currently handling that storing a field for each text area, but I'm sure there are better ways and I'd love to hear your opinions and come up with a better way.


When are you processing the markup the user enters? Are they ever going to need to re-retrieve it?

I'd do this by having three attributes on my model: original_text, markup_language (which is either textile, markdown, or bbcode), and rendered_text. When the user hit save, I'd save the text and use the value they provided for markup_language to figure out what renderer to use to store it into rendered_text.

0

精彩评论

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