Sunit Joshi Sunit Joshi - 1 year ago 125
Jade Question

Jade variable interpolation

I'm trying to interpolate jade variable in an image source and it doesn't seem to be working. Normal p tags work though!

- var lat=34.768464;
- var long=-86.346556

- var mapUrl = "{lat},#{long}&zoom=17&size=400x350&sensor=false";

p Latitude: #{lat}, Longitude: #{long}


I run it in cmd line and get this output:

<img src="{lat},#{long}&amp;zoom=17&amp;size=400x350&amp;sensor=false">


Any ideas what I'm doing wrong here ?


Answer Source

Variable interpolation doesn't work that way, you want:

var mapUrl = ""+lat+","+long+"&zoom=17&size=400x350&sensor=false";

You want to concatenate the two strings in Jade's JS runtime, not in the page url.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download