Slim - Having trouble nesting an element
-
02-01-2020 - |
Question
I cannot figure this out. For some reason my code below is producing this error:
syntax error, unexpected keyword_do, expecting keyword_end
Code:
header.full-width-row
.columns.large-4
.field-with-icon
== fa_icon 'search'
== search_field :user, :name, class: 'left', placeholder: "search"
.columns.large-8
.button-bar
ul.button-group
li.tiny.button.filterable-tab.active data={ tabvalue: '*'} =("All #{@users.count}")
- User.statuses.each do |tab_value|
li
a.tiny.button.filterable-tab data=({tabvalue: tab_value[0].to_s}) =(tab_value[0].to_s.capitalize)
label test
The error is caused by the label on the last line. When it is removed the page loads perfectly. I am wondering why I cannot nest this label?
Solution
You already defined a.tiny.button.filterable-tab
content in the line before the label, when you added =(tab_value[0].to_s.capitalize)
at the end.
Change the last two lines
a.tiny.button.filterable-tab data=({tabvalue: tab_value[0].to_s}) =(tab_value[0].to_s.capitalize)
label test
to
a.tiny.button.filterable-tab data=({tabvalue: tab_value[0].to_s})
= tab_value[0].to_s.capitalize
label test
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow