0
我需要在javascript中获得句柄模板。 所以我创建TPL文件夹模板文件和XML来自javascript的网络资源
<resource type="download" name="tpl/" location="/tpl"/>
写了这样行,如果我把一些图像到这个文件夹,我可以从CSS
.css
{
background: url(tpl/image.png);
}
得到它,如果我要得到这个图片来自js AJS.$("css").css("background", "url(tpl/image.png)")
我有错误 - 文件未找到;
图像文件是例如。在真正的我需要模板
AJS.$.ajax({
url: "tpl/backlog_coll.handlebars",
cache: true,
success: function(data) {
source = data;
template = Handlebars.compile(source);
$('#backlog_coll').html(template);
}
});
这种方法不发现模板了。它应该像'/jira/s/ru_RU-g6ghuq/773/3/1.0-SNAPSHOT/_/download/resources/com.swan.agile.swan-agile:swan-agile-scrumboard/tpl/“+ strName + “.handlebars' – waldemar
实际上,在我的例子中,为了便于解释,我将路径硬编码为”tpl“。实际上,您应该将其作为变量值取出,以便您可以动态地填充该模板的路径,如下所示: 函数fnGetTemplate(strPath,strName)if(Handlebars.templates === undefined || 模板:fnGetTemplate(strPath,strName);这个模板可以用来创建一个或多个模板。 – eshcol