玉模板引擎带按钮的href标签

时间:2016-03-26 09:45:57

标签: pug

如何链接玉石模板中的按钮?我正在尝试生成HTML

<a href="create"><button type="button">create new post</button></a>

我试过

a(href="create") button "create new post"

导致

<a href="create">button "create new post"</a>

如果我将其更改为

a(href="create")button "create new post"

我收到错误

logJs\views\posts\update.jade:7 5| block content 6| h1='creating new post' > 7| a(href="create")button "hello word" 8| form(name="add-post",method="post") 9| div.input 10| span.label title Unexpected token `tag` expected `text`, `code`, `:`, `newline` or `eos`

2 个答案:

答案 0 :(得分:13)

您只需要使用单独的行和正确的缩进。玉码

a(href="create")
   button(type="button") create new post

结果

<a href="create"><button type="button">create new post</button></a>

答案 1 :(得分:3)

还有一个解决方案:

a(href="create"): button(type="button") create new post

它也适合你!

相关问题