Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jade template engine a href tag with button

Tags:

pug

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`
like image 573
Arash Avatar asked Mar 26 '16 09:03

Arash


2 Answers

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>
like image 156
jsfan Avatar answered Dec 30 '22 22:12

jsfan


One more solution:

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

It will work for you too!

like image 31
Igor Ivancha Avatar answered Dec 30 '22 21:12

Igor Ivancha