☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Inserting a python variable to template string to use HTMLTemplateFormatter

Community Support
ahmettemiz88
ahmettemiz88

Hi,

Is there any better way to insert a python variable to template string to use
HTMLTemplateFormatter

I did:
kast=‘Kastamonu’
template_il="""<div style=“background:<%=
(function colorfromint(){
if (il.indexOf(’”""+kast+"""’) !== -1){
return(“orange”)}
}()) %>;
color: black">
<%= value %>

“”"
formatter_il = HTMLTemplateFormatter(template=template_il)

when I used python string format:
I got:
“”".format(kast)
ValueError: unexpected ‘{’ in field name

regards

⌁   Link to post

End of archived discussion · Replies are disabled