Pug dynamic image src interpolation
Asked Answered
A

1

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}
Armillia answered 25/11, 2017 at 8:17 Comment(0)
H
14

do it like this

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

and read this

Herra answered 25/11, 2017 at 14:28 Comment(1)
Just realized I was using the deprecated version. The new version looks something like img(src=img). pugjs.org/api/migration-v2.htmlArmillia

© 2022 - 2024 — McMap. All rights reserved.