开发者

Adding a div element in rails

i am having a helper function as

 def link_to_user(text, user, options = {})
options[:class] = options.has_key?(:class) ? "#{options[:class]} user-link" : ""
content_tag :span, :class => :vcard do
  link_to(text, user, options) +
  content_tag(:span, :style => "display: none;", :class => "userbox") do
    content_tag(:span, :class => "fn") d开发者_Python百科o
      content_tag(:span, :class => "given-name") do user.firstname
       end +
      content_tag(:span, :class => "family-name") do #user.lastname 
       end
    end 
  end
end 

end

now i am trying to add a div element as a sibling to vcard span. i tried but i am getting errors as syntax error, unexpected '+', expecting kEND (SyntaxError)

please give suggestions


Have you tried:

@content = content_tag :span, :class => :vcard do
    link_to(text, user, options) +
    content_tag(:span, :style => "display: none;", :class => "userbox") do
      content_tag(:span, :class => "fn") do
        content_tag(:span, :class => "given-name") do user.firstname
        end +
        content_tag(:span, :class => "family-name") do #user.lastname 
        end
      end 
    end
  end
@content << content_tag(:div, "etc")


first of all, the syntax for passing an argument to a block is

method_call do |arg|

you are missing the pipes (|)

secondly, you are missing an end

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜