yourcelf / olwidget

Javascript library to replace textareas that contain WKT data with editable OpenLayers maps, and a django app using it for django forms and admin.
Other
91 stars 43 forks source link

Pass the wkt_array to the InfoMap template context #17

Closed onurmatik closed 14 years ago

onurmatik commented 14 years ago

Hi,

In a case where I need to apply a template filter to the html passed to the info_map.html template, I need to access the info_array before it is rendered as a json string.

In my case, I am passing a link to an image as the html and applying a custom filter to create its thumbnail to be displayed on the map.

Thus, I suggest adding:

'wkt_array': wkt_array

to the context used to render the info_map.html by the render() method of the InfoMap.

Thanks, omat

yourcelf commented 14 years ago

Would it not be cleaner to pass the HTML through whatever filters you need by rendering them prior to adding them to InfoMap? e.g.:

InfoMap([ geom, Template("{{ thing|filter }}").render({'thing': thing}))])

Otherwise, you'd be forced to reconstruct the javascript array in the template, which seems to eliminate the point a bit. I mean, you could also just skip the Django InfoMap class altogether and invoke olwidget.InfoMap in the javascript directly, which would not be much different from what you're suggesting. The point of the Django class is to avoid having to write the javascript.

onurmatik commented 14 years ago

Makes perfect sense, thank you.

yourcelf commented 14 years ago

cool.