5

I have stored a dynamic url link into a pug variable #{img}. Now I want to include that variable into my image element. Can anyone help me fill in the blank?

#{img} //some dynamic url
img(src=" ") //want to set src = #{img}
David
  • 303
  • 3
  • 8
  • 21

1 Answers1

14

do it like this

- var img = "img/test.jpg"
img(src=img)

and read this

Vladlen Samb
  • 156
  • 1
  • 2
  • Just realized I was using the deprecated version. The new version looks something like img(src=img). https://pugjs.org/api/migration-v2.html – David Nov 25 '17 at 20:26