Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom Template class with tojavascript filter #1912

Merged

Conversation

Conengmo
Copy link
Member

@Conengmo Conengmo commented Apr 3, 2024

Based on #1856, split off from the more complete version in #1895.

Add a custom Template class that contains the tojavascript template filter that converts Python objects to Javascript notation. This may include Javascript object references or functions.

Instead of applying this template everywhere at once, we'll adopt is gradually where it is useful. This is mainly when one of the arguments is a Javascript function or when we want to reference another Folium object in the Javascript template.

@Conengmo
Copy link
Member Author

Conengmo commented Apr 3, 2024

@hansthen want to do a final review of this one?

@Conengmo Conengmo added the waiting for review PR is waiting to be reviewed label Apr 3, 2024
Copy link
Collaborator

@hansthen hansthen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I also like the comprehensive tests. As a future enhancement, I think the to_javascript filter may benefit from pretty indentation, but that should not block this change.

@Conengmo
Copy link
Member Author

Conengmo commented Apr 3, 2024

As a future enhancement, I think the to_javascript filter may benefit from pretty indentation, but that should not block this change.

Good idea!

And thanks for the review!

@Conengmo Conengmo removed the waiting for review PR is waiting to be reviewed label Apr 3, 2024
@Conengmo Conengmo merged commit a3034f9 into python-visualization:main Apr 3, 2024
12 checks passed
@Conengmo Conengmo deleted the tojavascript-template-filter branch April 3, 2024 14:49
hansthen pushed a commit to hansthen/folium that referenced this pull request Apr 3, 2024
Conengmo added a commit that referenced this pull request Apr 4, 2024
* Re: #1606 Add TreeLayerControl to Folium

* add custom Template class with tojavascript filter (#1912)

* Drop Bootstrap 3 and use separate glyphicons css file (#1914)

---------

Co-authored-by: Frank Anema <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants