Question

I have a form and a button:

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

it is converted to rails from the twitter bootstrap [ http://getbootstrap.com/components/#alerts ]:

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

But the rails variant getting an error:

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)); 
...                               ^

Something with aria-hidden: "true" or dismiss: "alert" is wrong

Why is it so? I used different variants which complains to [ http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-button_tag ]:

button_tag(content_or_options = nil, options = nil, &block)
Was it helpful?

Solution

This syntax is not allowed:

aria-hidden: "true"

Replace it with:

:"aria-hidden" => "true"

or

"aria-hidden" => "true"

or

aria: { hidden: true }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top