folium icon indicating copy to clipboard operation
folium copied to clipboard

Add template parameters to JsCode objects

Open hansthen opened this issue 9 months ago • 3 comments

Is your feature request related to a problem? Please describe. I'd like to be able to refer to other folium /leaflet objects inside a JsCode object. So far I have been using string interpolation inside the body of the JsCode object.

Describe the solution you'd like I'd like to add parameters to the JsCode __init__ method, together with a basic string templating solution. For the string templating I'd prefer to use the good-old %(name)s format.

Describe alternatives you've considered I considered using the newer formatting templates such as used in python format, or Jinja templates. However, due to brace heavy nature of javascript, I think a completely new variable marker will lead to more readable code.

Implementation folium is maintained by volunteers. Can you help make a PR if we want to implement this feature?

hansthen avatar Apr 06 '25 06:04 hansthen