content_tag inside content_tag

Hi

i tried content_tag inside content_tag bu its not working

<%= content_tag(:h1,“Arrange”+content_tag(:span,“Demo”))%>

i want like this type

Arrange Demo

plz help.

bye

call like this content_tag(:h1,raw(“Arrange”+(content_tag(:span,“Demo”))))

=> “

ArrangeDemo

kingston.s

More readably (IMO):

<%= content_tag :h1 do %>    Arrange <%= content_tag :span, 'Demo' %> <% end %>

kanna wrote in post #1118570:

Hi

i tried content_tag inside content_tag bu its not working

<%= content_tag(:h1,"Arrange"+content_tag(:span,"Demo"))%>

i want like this type

<h1>Arrange <span>Demo</span></h1>

More readably (IMO):

<%= content_tag :h1 do %>   Arrange <%= content_tag :span, 'Demo' %> <% end %>

What's wrong with just using standard HTML:

<h1>Arrange <span>Demo</span></h1>

Not sure how a bunch of nested content_tag() are 'more readable' than that.

Personally i hate the content_tag method. It just obfuscates your DOM.

hi

I tried

<%= content_tag(:h1,“Arrange”.html_safe + content_tag(:span," Demo"))%>

its coming fine.

thanks for everyone .

Is there any body who can explain the differences between using “standard HTML” and “content_tag”?

在 2013年8月14日星期三UTC+8上午5时27分08秒,Ruby-Forum.com User写道:

Standard HTML:

example

Content_tag:

content_tag :div, “example”

Thanks.

That’s what I know.

But how do I decide which to use?

Norbert Melzer wrote in post #1119014:

Standard HTML:

<div>example </div>

Content_tag:

content_tag :div, "example"

Thanks.

That's what I know.

But how do I decide which to use?

The most (and i'd say only) useful aspect of content_tag is the ability to iterate over a collection:

<%= content_tag_for(:tr, @people) do |person| %>   <td><%= person.first_name %></td>   <td><%= person.last_name %></td> <% end %>

which produces items with a predictable id and class.

<tr id="person_123" class="person">...</tr> <tr id="person_124" class="person">...</tr>

see doc: http://api.rubyonrails.org/classes/ActionView/Helpers/RecordTagHelper.html#method-i-content_tag_for

But in most cases where you just need standard tags, you should plain ol' html because it's much easier to maintain.

<h1><%= @person.name %></h1>

is better than

<%= content_tag :h1, @person.name %>