如何在需要双引号的地方插入包含双引号的流星模板? [英] How do I insert a meteor template that contains double quotes in a place where those double quotes are needed?
问题描述
.popular 在我的meteor web应用程序中,我试图用此代码有条件地更改某个元素的背景。 -games {
background-image:url({{background}});
}
{{background}}是找到图片时应遵循的路径。这将无法正常工作,因为url路径需要引号,并且当我在引号中放置{{background}}时不需要。我已经尝试将这些引号放入{{background}}源代码中:
background: \images / gameArt / fallout4.jpg\
试图在引号中添加,但由于某些原因,这仍然不起作用。任何帮助都会很棒。
< div style =background-image:url('{{imagePath}}');>< / div>
如果您返回的文件路径是正确的,那么它将起作用。
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.
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.
这篇关于如何在需要双引号的地方插入包含双引号的流星模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!