我希望在网页的不同部分使用嵌套模板。在不同的部分中,我需要从嵌套模板内的数组中获取值。我无法使用for循环,因为每个部分在网站上具有不同的类和位置。是否可以将变量传递到嵌套模板中?以下代码简化了我要实现的内容:
<script id="myBtnTmpl" type="text/x-jsrender">
<button class="btn">
{{:myData.myArray[INDEX_VARIABLE].btnName}}
</button>
</script>
// Here I want to use INDEX_VARIABLE = 0
<div class="BigButton">
{{if myData tmpl="myBtnTmpl"/}}
</div>
// Here I want to use INDEX_VARIABLE = 1
<div class="MediumButton">
{{if myData tmpl="myBtnTmpl"/}}
</div>
// Here I want to use INDEX_VARIABLE = 2
<div class="SmallButton">
{{if myData tmpl="myBtnTmpl"/}}
</div>
另一个问题:在使用嵌套模板时,是否可以像这样包含嵌套模板 {{tmpl="myBtnTmpl"/}} 而不需要 if 语法?
谢谢!