File tree Expand file tree Collapse file tree
templates/groundwork/geo/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 {% for key, val in values %}
66 {% if val %}data-map-{{key}}-value="{{val}}"{% endif %}
77 {% endfor %}
8- data-controller="map"
9- >
8+ data-controller="map">
109 {{slots}}
11- {% if in_place != True %}
12- {% include "groundwork/geo/components/map_canvas.html" %}
10+ {% if in_place is False %}
11+ {% comment %}It's up to the developer to place the map canvas{% endcomment %}
12+ {% else %}
13+ {% include "groundwork/geo/components/map_canvas.html" only %}
1314 {% endif %}
1415</ {{element}}>
Original file line number Diff line number Diff line change 1- < {{ element} }
1+ < {% firstof element "div" % }
22 {% for key, val in attrs %}
33 {% if val %}{{key}}="{{val}}"{% endif %}
44 {% endfor %}
5- data-map-target="canvas">
6- </ {{element}}>
5+ data-map-target="canvas"
6+ >
7+ </ {% firstof element "div" %}>
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ def map(
2424 api_key : Optional [str ] = None ,
2525 center : Any = None ,
2626 zoom : Optional [int ] = None ,
27+ in_place : Optional [bool ] = True ,
2728 children : Optional [template .NodeList ] = None ,
2829 ** attrs : Dict [str , str ],
2930) -> template .Node :
@@ -36,6 +37,7 @@ def map(
3637 return MAP_TEMPLATE .render (
3738 {
3839 "element" : element ,
40+ "in_place" : in_place ,
3941 "values" : (
4042 ("api-key" , api_key ),
4143 ("center" , center ),
Original file line number Diff line number Diff line change @@ -18,6 +18,34 @@ def test_renders_map(self):
1818 html ,
1919 )
2020
21+ def test_renders_map_in_place_false_without_canvas (self ):
22+ html = render_template (
23+ "{% load groundwork_geo %}"
24+ '{% map in_place=False class="w-100" zoom=9 %}'
25+ "{% endmap %}"
26+ )
27+
28+ self .assertInHTML (
29+ '<div class="w-100" data-controller="map" data-map-zoom-value="9" data-map-api-key-value="dummy">'
30+ "</div>" ,
31+ html ,
32+ )
33+
34+ def test_renders_map_in_place_false_with_canvas (self ):
35+ html = render_template (
36+ "{% load groundwork_geo %}"
37+ '{% map in_place=False class="w-100" zoom=9 %}'
38+ '{% map_canvas class="w-50" %}'
39+ "{% endmap %}"
40+ )
41+
42+ self .assertInHTML (
43+ '<div class="w-100" data-controller="map" data-map-zoom-value="9" data-map-api-key-value="dummy">'
44+ '<div class="w-50" data-map-target="canvas"></div>'
45+ "</div>" ,
46+ html ,
47+ )
48+
2149
2250def render_template (content : str ) -> Any :
2351 context = Context ()
You can’t perform that action at this time.
0 commit comments