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

152
Views
Pug template + interpolation from a function

I have a utility function which takes some text, and inserts hyperlinks via pug templating. For example:

function toPugLink(text, url) { ... }

toPugLink('test', 'stackoverflow.com') -> #[a(href='stackoverflow.com) test]

However, when I want to consume this, Pug does not seem to recognise it.

mixin body(data, utils)
  p #{utils.toPugLink(data.text, data.urlTokens)}

Instead, what is output is the literal value, rather than the tokenised template.

How can I tell pug to render my output as a pug template rather than a literal string?

This is a simplified version of my code. The full version contains large amounts of text, the function replaces multiple tokens, etc, so quick workarounds sadly can't be used here.

about 4 years ago · Juan Pablo Isaza
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!