Wednesday, 31 May 2017

Background-img style attribute issue with Pug templates

I can't understand what URL I should use to get Pug to load images from the public folder.

I'm using Pug as template engine to render the views from a Node.JS (Express) server.

This is the relevant code:

li
  .image(style='background-image: url(img/'+article.img');')
  h4= article.title
  a.btn(href='#') Read more

What I'm sure it's not the culrpit:

  • I'm sure article.img value is correct

  • I'm sure the server is serving other files correctly from the public folder, since stylesheets and script files are loaded correctly.



via fbid

No comments:

Post a Comment