开发者

jade outputs relative links

I'm starting to play with node, express and jade and when I do this

a(href="http:/www.example.com/" + variable) variable

I get a relative开发者_如何学Go link, say

<a href="http://127.0.0.1:3000/www.example.com/mytext">mytext</a>

Instead of the absolute link.

I'm guessing I'm doing something wrong with the enviroment stuff, any ideas?

Thanks!


Have you noticed that you have only ONE slash in your http:/ protocol. You need two.

I didn't think jade did any processing whatsoever of those attributes, once computed. Actually, with jade 0.12.4, I can't reproduce your behavior. Jade outputs <a href="http:/www.example.com/mytext">variable</a>'. Note that the second instance ofvariable` is a string literal, not interpreted javascript code (this is by design). You want

a(href="http://www.example.com/" + variable)= variable

to get your desired output.

Try updating to the latest jade to be sure, but I doubt jade is the issue.

My guess is jade is actually outputting the raw HTML correctly and that you are looking at the URL in your browser's status bar when you mouseover the link? Maybe the browser is doing that conversion to an absolute URL due to your missing slash?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜