Bgcolors as Variables Not Working As Expected

I am trying to set colors for my tables inside a javascript file so that I can easily change colors if I need to without editing every single file where it’s stated bgcolor="#4d5777".

However, when I try to include the colors, I am getting completely unexpected colors.

I have attached a gist to show what I am talking about.

You might need to encode it, # to %23m actually never mind it doesn’t seem to work…but it works with <td bgcolor="{$colors.dk_blue}">, you’re missing the curly brace to interpolate

So I see you used the {} around the whole variable as opposed to ${variable}?

What is the difference?

I tried the interpolation like you suggested (see my gist), but the color it is returning is still not the right color?

I also added encodeURIComponent to the color dk_blue to see if that helped, and it did not.

It’s still the wrong blue.

@bigopon any idea why bgcolor="${colors.lt_blue}" doesn’t work?

Another thing is that bgcolor is a deprecated attribute, you can use standard style attribute to set any css style. Following works.

<table style="background-color:${colors.lt_blue}">
1 Like