我有辅助功能
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") do
content_tag(:span, :class => "given-name") do user.firstname
end +
content_tag(:span, :class => "family-name") do #user.lastname
end
end
end
end
端
现在我正在尝试添加div元素作为vcard span的兄弟。我试过,但我得到错误的语法错误,意外的'+',期待kEND(SyntaxError)
请提出建议
答案 0 :(得分:2)
你试过了吗?
@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")
答案 1 :(得分:0)
首先,将参数传递给块的语法是
method_call do |arg|
你错过了管道(|
)
其次,您错过了end