javascript - Rendering Limited Number of Object in Mustache.js -


i geting nested json object want render on html page. length , content of object can vary , want show part of it. not know how using mustache.js

my object looks this:

{ "success": [   {     "stopid": "123",     "stopname": "abc",     "lines": [       {         "lineref": "3",         "destinationid": "987",         "destinationname": "def",         "arrivals": [           1490279520000,           1490279460000,           1490280180000         ]       }     ]   },   {     "stopid": "331",     "stopname": "tvc",     "lines": [       {         "lineref": "3",         "destinationid": "128",         "destinationname": "njh",         "arrivals": [           1490279160000,           1490280180000         ]       },       {         "lineref": "3v",         "destinationid": "361",         "destinationname": "koi",         "arrivals": [           1490280360000         ]       }     ]   },   {     "stopid": "3601",     "stopname": "lkg",     "lines": [       {         "lineref": "3",         "destinationid": "128",         "destinationname": "abc",         "arrivals": [           1490279040000,           1490280360000,           1490280180000,           1490280180000         ]       }     ]   } ]} 

i want display maximum of 2 arrivals, how can put limit there.

i found this not help. code this:

<script id="#timetables" type="text/template">     {{#success}}     <tr style = "">        <th colspan="3" style="padding-left:25px;">{{stopname}}<span><sup style="padding-left:5px;font-weight:100"><small>{{stopid}}</sup></span></th>        </tr>        {{#lines}}        <tr class="line-row">            <td class="" style="border:none;width:10%;">{{lineref}}</td>           <td class="" style="border:none;width:30%;">{{destinationname}}</td>           <td class="" style="border:none;width:60%;">{{arrivals}}</td>          </tr>         {{/lines}}        {{/success}}   </script> 


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -