I’m trying to make a shortcode for a leaflet map with a GPX file displayed. I’m calling it like {{ leaflet(id="map", gpx="/path/to/gpx") }}.
In the shortcode, the variable gpx is referenced like this: var gpx = "{{gpx}}";
However, when the website compiles it shows up in public HTML as: /path/to/gpx
I assume this is because Tera is URL Encoding the variable, but I don’t know why it would be doing that and I would like to know how to stop it from doing that.
Tera escapes everything, it doesn’t know that is it a URL. There is https://github.com/Keats/tera/issues/368 to have a URL specific escaping scheme but not implemented yet.
You can do var gpx = "{{gpx | safe}}"; in the meantime if you don’t let a user specify a URL.
Yeah, it’s me linking to my own files on my own server. Thanks for the tip. Additionally, I would love to know how to debug my mess of Javascript code for my map shortcode. I’m having issues when I try to insert more than one map per page. I’ll post a gist with the errors I’m getting and the code I’m using.