How do I insert a meteor template that contains double quotes in a place where those double quotes are needed?

隐身守侯 提交于 2019-12-25 06:26:28

问题


In my meteor web app I am trying to change the background of a certain element conditionally with this code:

.popular-games{
  background-image: url({{background}});
}

{{background}} being the path it should follow to find the image. This will not work though because the url path needs quotes, and when I put in quotes in negates {{background}}. I've tried putting the quotes into the source where {{background}} is coming from with this code:

background: "\"images/gameArt/fallout4.jpg\""

trying to add in the quotes, but this still does not work for some reason. Any help would be great.


回答1:


You need to have the style in your html like this:

<div style="background-image: url('{{imagePath}}');"></div>

If the file path you return is correct, it will work.



来源:https://stackoverflow.com/questions/37099293/how-do-i-insert-a-meteor-template-that-contains-double-quotes-in-a-place-where-t

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