0

我有一个表单和一个按钮:

= button_tag( "×" , type: "button", html: {class: "close", aria-hidden: "true"},  data: {dismiss: "alert"} )

它从 twitter bootstrap [ http://getbootstrap.com/components/#alerts ] 转换为 rails:

<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>

但是 rails 变体出现错误:

SyntaxError in Search#get_search
Showing /.../app/views/search/new.html.slim where line #58 raised:

/.../app/views/search/new.html.slim:58: syntax error, unexpected tLABEL
...: {class: "close", aria-hidden: true},  data: {dismiss: "ale...
...                               ^
/.../app/views/search/new.html.slim:58: syntax error, unexpected ')', expecting keyword_end
... {dismiss: "alert"} )))).to_s)); 
...                               ^

有问题aria-hidden: "true"dismiss: "alert"有问题

为什么会这样?我使用了不同的变体来抱怨 [ http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-button_tag ]:

button_tag(content_or_options = nil, options = nil, &block)
4

1 回答 1

1

不允许使用此语法:

aria-hidden: "true"

将其替换为:

:"aria-hidden" => "true"

或者

"aria-hidden" => "true"

或者

aria: { hidden: true }
于 2013-10-15T14:43:18.920 回答