How to set source of the image a variable in a pug template?

筅森魡賤 提交于 2020-06-23 14:01:26

问题


While creating a movie info platform, I wanted to print image posters. I was unable to set the source of the image to a variable in pug.

      each movie in movies
         .col-md-3(style="margin-bottom: 20px;")
             .text-center
                img(src= "#{movie.Poster}" style="width:100%; height:200px; padding: 0px 40px;")
                    h5(style="padding: 5px 40px 0px 40px;") #{movie.Title}
                    h5 #{movie.Year}

回答1:


If you have image source stored in movie.Poster, then I think you should try something like this:

img(src=movie.Poster)

You can read more about attribute interpolation in the Pug documentation.



来源:https://stackoverflow.com/questions/62246360/how-to-set-source-of-the-image-a-variable-in-a-pug-template

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!