newbie
newbie

Reputation: 14950

JSRender how to access variable outside the block

I am using a jsrender to show the details of my json object. 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>

Upvotes: 2

Views: 1747

Answers (1)

webdeveloper
webdeveloper

Reputation: 17288

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>

Upvotes: 3

Related Questions