Search code examples
javascriptnode.jspug

use boolean locals in pug


I use pug in nodejs and want to pass boolean locals to pug file and if conditions based on this local.

how can I use firstnameProblem on pug file in if condition like blow?

email.js:

email.send({
    template: template,
    message: { to: 'a@a.com' },
    locals: {firstnameProblem:false}
  });

html.pug:

 ul
      if ${firstnameProblem}
           li Problem in first name

Solution

  • I found my answer, I can use locals like variable in pug like blow:

    html.pug:

    ul
          if firstnameProblem
               li Problem in first name