ruby on rails - Using RDiscount, where should I do the actual formatting? -
i'm using rdiscount ruby on rails skills limited. rdiscount has .to_html function converts markdown text html. here's scenario:
<% @posts.each |post| %>
<h3><%= post.title %></h3>
<%= post.content %>
<% end %>
post.content want convert html.
1) should create method convert string html?
2) how stop ror escaping html rdiscount.to_html returns?
1) preferably, in helper 2) calling html_safe on resulting string
i have not used markdown in rails 3 app, escapes content default, created helper similar h
method prior rails 3, converted markdown html. approach rails 3 like
module helper def m(string) rdiscount.new(string).to_html.html_safe end end
in view
<% @posts.each |post| %> <h3><%= post.title %></h3> <%= m post.content %> <% end %>
Comments
Post a Comment