Skip to content
All posts

Correct background color style snippet in HubL

I get frustrated when I copy a style code snippet and I am given:

{{ module.style.background_color.color }}
{{ module.style.background_color.opacity }}

 

When the correct code is:

{% if module.style.background_color.color %} style="background-color: rgba({{ module.style.background_color.color|convert_rgb }}, {{ module.style.background_color.opacity / 100 }});

 

Try it today! I use this a lot and it should be easier ;-) Always use if statements around your field codes!