diff --git a/folium/templates/fit_bounds.js b/folium/templates/fit_bounds.js deleted file mode 100644 index 70429698bf..0000000000 --- a/folium/templates/fit_bounds.js +++ /dev/null @@ -1,11 +0,0 @@ -{% if autobounds %} -var autobounds = L.featureGroup({{ features }}).getBounds() -{% if not bounds %} -{% set bounds = "autobounds" %} -{% endif %} -{% endif %} -{% if bounds %} -{{this._parent.get_name()}}.fitBounds({{ bounds }}, - {{ fit_bounds_options }} -); -{% endif %} diff --git a/tests/test_folium.py b/tests/test_folium.py index 1620bd1b4b..3ddba76c4a 100644 --- a/tests/test_folium.py +++ b/tests/test_folium.py @@ -14,7 +14,7 @@ import pandas as pd import pytest import xyzservices.providers as xyz -from jinja2 import Environment, PackageLoader +from jinja2 import Template from jinja2.utils import htmlsafe_json_dumps import folium @@ -78,7 +78,21 @@ def setup_method(self): font_size="1.5rem", attr=attr, ) - self.env = Environment(loader=PackageLoader("folium", "templates")) + self.fit_bounds_template = Template( + """ + {% if autobounds %} + var autobounds = L.featureGroup({{ features }}).getBounds() + {% if not bounds %} + {% set bounds = "autobounds" %} + {% endif %} + {% endif %} + {% if bounds %} + {{this._parent.get_name()}}.fitBounds({{ bounds }}, + {{ fit_bounds_options }} + ); + {% endif %} + """ + ) def test_init(self): """Test map initialization.""" @@ -394,8 +408,7 @@ def test_fit_bounds(self): ][0] out = self.m._parent.render() - fit_bounds_tpl = self.env.get_template("fit_bounds.js") - fit_bounds_rendered = fit_bounds_tpl.render( + fit_bounds_rendered = self.fit_bounds_template.render( { "bounds": json.dumps(bounds), "this": fitbounds, @@ -415,8 +428,7 @@ def test_fit_bounds_2(self): ][0] out = self.m._parent.render() - fit_bounds_tpl = self.env.get_template("fit_bounds.js") - fit_bounds_rendered = fit_bounds_tpl.render( + fit_bounds_rendered = self.fit_bounds_template.render( { "bounds": json.dumps(bounds), "fit_bounds_options": json.dumps(