why should I use content_tag instead of "regular" html?

Viewed 1785

I know that there is an option to use the content_tag function in ruby-on-rails, which helps to generate an html tag. Some rails developers in a company I work with told me that this is the "convenient and proper" way and I should not write a "native" html in order to generate a div for example... Is it true? Is it a kind of rails standard? Does it have something to do with performance issues or render speed?

I attach the codes for my previous code:

<div class="alert alert-<%= key %>"><%= value %></div>  

and the rails function usage

<%= content_tag(:div, value, class: "alert alert-#{key}") %>

The first looks to me pretty, understandable and intuitive - more than the second code.. What do you think about that?

3 Answers
Related