I wanna change bootstrap sass variables from the views and I have tried internal css and it doesn't work any ideas:
<% if current_user.admin == true%>
<!-- Change sass variables-->
<% else %>
<!-- use default sass variables -->
<% end %>
I wanna change bootstrap sass variables from the views and I have tried internal css and it doesn't work any ideas:
<% if current_user.admin == true%>
<!-- Change sass variables-->
<% else %>
<!-- use default sass variables -->
<% end %>
SASS variables cannot be changed on erb templates. One way to do it is by defining different CSS classes with the help of SASS mixins for each of these if .. else
cases. For example:
SASS rules:
$default-color: #666;
$admin-color: #333;
@mixin common-style($color) {
color: $color;
padding: 10px;
border: 1px solid black;
}
.default-div {
@include common-style($default-color)
}
.admin-div {
@include common-style($admin-color)
}
Then, on your view file:
<% if current_user.admin == true%>
<!-- use admin CSS -->
<div class='admin-div'>
</div>
<% else %>
<!-- use default CSS rules -->
<div class='default-div'>
</div>
<% end %>