Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic Links with Jade

Using Jade + Express + Node.js + Mongoose + MongoDB for my app, but this issue I ran into is likely in Jade:

I have some code as follows that prints a list of posts by title, author

div#articles
      -each post in records
         div.article
            #{post.title} was written by #{post.author}
            <a href ="#{post.title}"> Link to Article </a>

Now I want to the link in written Jade instead of HTML, but when I replace the line with

a(href='#{post.title}')

it links to /#{post.title} instead of the variable name such as /newpost1. Doing it as

a(href=#{post.title})

returns an error. I'm sure this is a syntax issue, but I can't find the solution in the GitHub documentation

like image 664
varunsrin Avatar asked Apr 18 '11 02:04

varunsrin


Video Answer


1 Answers

pretty sure you can just do:

a(href=post.title)
like image 170
busticated Avatar answered Oct 25 '22 07:10

busticated