I want to add some css style that I calculate in my ruby code within a haml
template.
I understand that I should use the :css
filter to add a style
tag for my css like this:
%head
- my_color = "#0000ff"
:css
.my-class {
/ how can I set my_color here:
background-color: red;
}
But how can I use my_color inside the filter?
Edit: To be clear, I am looking for a <style>
tag, not inline css on an element.
CodePudding user response:
You can interpolate the variable with #{my_color}
:
- my_color = "#0000ff"
:css
.my-class {
background-color: #{my_color};
}