Reputation: 312
I'm trying to set an image url in jade...
I have this: img(src = 'http://192.168.1.8:8081')
I need to change 192.168.1.8 automatically with the server address...
For example if I connect to my server from office, my url should become img(src = 'http://myPUBLICserveraddress:8081')
How can I do this?
Thanks
Upvotes: 0
Views: 9809
Reputation: 8727
I do this with Dust.js, but the principle should be the same. The way I do this is to set a hostname
and port
attribute on the app for both development and production (which is assigned in app.configure('development')
and app.configure('production')
), and then in the templates, I just do the Dust.js equivalent of:
- if (port)
img(src="http://#{host}:#{port}")
- else
img(src="http://#{host}")
And I get what I'm looking for, which is the right link based on the environment (dev vs production).
Upvotes: 2