Saturday 20 May 2017

Trying to use PugJS to iterate both href attribute and link text

I'm having a hard time taking my json object and using the name and values to make a link. I've tried separate arrays as well, but I've decided it'd be easier if I set the object as {title:url} and when I use this code:

      ul
    each url, title in news
      li= title
      li= url

it returns my titles and urls like so

  • These are the arguments against net neutrality — and why they’re wrong
  • https : //techcrunch . com/2017/05/19/these-are-the-arguments-against-net-neutrality-and-why-theyre-wrong/
  • The bizarre naming trends that modern startups follow
  • https: //techcrunch . com/2017/05/20/the-bizarre-naming-trends-that-modern-startups-follow/
  • Salesforce marches steadily toward $10B run rate goal
  • https :// techcrunch . com/2017/05/19/salesforce-marches-steadily-toward-10b-run-rate-goal/
  • Uber threatened to fire engineer at center of Waymo trade secret lawsuit
  • https : //techcrunch.com/2017/05/19/uber-waymo-anthony-levandowski-termination-threat/

but when I try to make links with this code

   each url, title in news
    a(href= url) title

I get this:

titletitletitletitle

the links work, but it won't iterate the title... any tips with this issue?



via Quoc Moon Duong

No comments:

Post a Comment