Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
How to render array parameter in pug file

I want to use a pug template file to render html. Here is the pug file temp1.pug:

h1 hello!
p here is my friends:
  ul
    each val,index in !{friends}
      li='friend'+(index+1)+ ' ' + val

I want to render the pug file by using array in parameter friends:

const templateRender = pug.compileFile('./temp1.pug');
console.log(templateRender({friends:['aaa','bbb']}));

It is supposed to have the output like:

<h1>hello!</h1>
<p>here is my friends:
<ul>
<li>friend 1: aaa</li>
<li>friend 2: bbb</li>
</ul>
</p>

but the actual output is:

<h1>hello!</h1>
<p>here is my friends:
<ul></ul>
</p>

It seemed that pug complier completely ignore my array input. Is there any idea to use array parameters to render this page?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Please try this:

each val,index in friends
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!