SDB_1998
SDB_1998

Reputation: 365

Problem passing a variable in pug template engine language

I am passing a url to the pug template

img.img_pattern(src= '#{url}'+'/pattern.svg' alt='pattern')

But this is not working. Anyone have an idea how to pass a variable to an src

Upvotes: 2

Views: 87

Answers (1)

antlis
antlis

Reputation: 425

You can use backticks, template literals. Example below.

- var url = "duckduckgo"
 img(src=`https://external-content.${url}.com/iu/?u=http%3A%2F%2Ftechtrends.intelegain.com%2Fwp-content%2Fuploads%2F2019%2F01%2FDuckDuckGo.jpg&f=1&nofb=1`)

https://codepen.io/antlis/pen/BaRQQGr

Upvotes: 2

Related Questions