2016-07-14 24 views
0

当我在段落中添加链接时遇到问题。Jade模板 - 使用URL作为链接标签

玉模板语法:

p Here is link to #[a(href='https://google.com/') google link] 

结果是:这里是链接到google link

我要的是:这里是链接到https://google.com/

我试过这个语法,但它不起作用:

p Here is link to #[a(href='https://google.com/') https://google.com/] 

如果链接显示有http://https://,则会发生错误。

感谢您的帮助!

+0

这似乎工作:'#[a(href ='https://google.com/')google.com]'尽管您将会忽略标签中的http://部分。 – Waylan

+0

Yeap,问题来了,因为'http://'或'https:// –

回答

1

看来你可以使用降价过滤器写的段落里你的链接:

p 
    | Here is link to 
    a(href='https://google.com/') https://google.com/ 

编辑1

它也可以用当地人做..

{ 
    URL: 'https://google.com/' 
} 

..和插值:

p Here is link to #[a(href='#{URL}') #{URL}] 

EDIT 2

如果单引号没有障碍,只是做:

p Here is link to #[a(href='https://google.com/') 'https://google.com/'] 

编辑3

这是完全一样的编辑1但没有当地人:

p Here is link to #[a(href='https://google.com/') #{'https://google.com/'}] 
+0

我想为段落里的'a tag'制作玉模板,因为单个段落中的很多超链接和其他一些标签,如果我把它分解到下一个链接,那么玉代码对每个标签来说都太深了。 –

+0

@HuyNguyen说实话,看来,我不明白你在评论中究竟是什么意思,但我用一些额外的案例更新了答案。 –

+0

@HuyNguyen请再看一个更新。 –