Skip to content

Add template parameters to JsCode objects #2121

Open
@hansthen

Description

@hansthen

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions