玉模板 - 使用URL作为链接标签

时间:2016-07-14 14:13:06

标签: javascript pug

我在段落中添加链接时遇到问题。

jade模板语法:

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://,则会发生错误。

感谢您的帮助!

1 个答案:

答案 0 :(得分: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}]

编辑2

如果单引号不是障碍,只需执行:

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

编辑3

EDIT 1 完全相同,但没有本地人:

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