我正在尝试使用 content_tag 和 safe_concat 连接多个标签,例如:
content_tag(:select, multiple: "multiple", :name => "contact[resources]") do
content_tag(:optgroup, label: "LABEL", id: "some-id") do
safe_concat(
if condition1
(content_tag(:option, value: "val1") { "Val1" } )
end
if condition2
(content_tag(:option, value: "val2") { "Val2" } )
end
)
end
end
但我不断收到以下错误:
syntax error, unexpected keyword_if, expecting ')'
syntax error, unexpected end-of-input, expecting keyword_end