[英]JSRender how to access variable outside the block
I am using a jsrender to show the details of my json object. 我正在使用jsrender显示json对象的详细信息。 I am wondering how I can access the outside variable inside the list.
我想知道如何访问列表中的外部变量。 Thank you.
谢谢。
<script id="itemTemplate" type="text/x-jQuery-tmpl">
{{=outsideVariable}} //STRING
<div id="receipt_list_container">
{{#each receiptSummary.receipts}} //LIST
{{=formattedMonth}}
//HOW CAN I ACCESS THE OUTSIDE THE VARIABLE
{{/each}}
</div>
</script>
As I understand, this is your example: Example Scenario: Accessing parent data. 据我了解,这是您的示例: 示例方案:访问父数据。
var model = {
specialMessage: function(...) { ... },
theater: "Rialto",
movies: [ ... ]
}
{{for movies}}
<tr>
<td>'{{>title}}': showing at the '{{>#parent.parent.data.theater}}'</td>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.