0

Its a simple task i want to pass on the color eg: "rgb(255,255,0)" to the html file so that the text color can be changed.

I used this snippet in the html file

``{% for i in range(0,len) %}
new mapboxgl.Marker({
    color: {{ colors[i]|safe }}
    }).setLngLat([
        {{ lang[i] }}, 
        {{ lat[i] }}])
    .addTo(map);

    {%endfor%}

i am passing the colors list by:

colors=[]
maxValue = max(totalConfimedList)
for item in totalConfimedList:
    print(item)
    # colors.append(code_map(int(item),0,int(maxValue),0,255))
    if int(item) >255:
        colors.append("\'rgb(255,0,0)")
        continue
    colors.append("\"rgb("+item+"0,0)\"")

In HTML IN CHROME it is coming as color: "rgb(200,0)" The color is not coming. Please help me

DevHyperCoder
  • 895
  • 1
  • 9
  • 22

1 Answers1

-1
colors = []
totalConfimedList = ['123', '255', '256', '375', '367']
maxValue = max(totalConfimedList)
for item in totalConfimedList:
    print(item)
    # colors.append(code_map(int(item),0,int(maxValue),0,255))
    if int(item) > 255:
        colors.append('rgb(255,0,0)')
        continue
    colors.append('rgb('+item+',0,0)')

jinja 2 template:-

{% for i in colors %}
color: [{{ i|safe }}]
{%endfor%}

enter image description here