Arash
Arash

Reputation: 3688

jade template engine a href tag with button

How can I link a button in jade template? I am trying to generate the HTML

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

I tried

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

which results in

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

If I change it to

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

I get the error

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`

Upvotes: 6

Views: 16148

Answers (2)

Igor Ivancha
Igor Ivancha

Reputation: 3451

One more solution:

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

It will work for you too!

Upvotes: 4

jsfan
jsfan

Reputation: 1373

You just need to use a separate line and the correct indentation. The jade code

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

results in

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

Upvotes: 13

Related Questions