jquery - dustjs xpath parent equivalent -


i'm trying pretty simple: i'd show nba teams conference, isn't structure of json.

i don't want ask rest service structure change, i.e., make teams child array of conference node.

this presentation issue, i.e., json has data need, how can present using dustjs?

you can see jsfiddle attempt here: xpath equivalent jsdust

<script id="league-template2">     <div class="conference">      <h3>[i want put conference name here eg eastern] conference</h3>     {#teams}            <ul>             {#properties}                             {@eq key=name value="numeric"}                     <li class="teamname teamdd_{value}">                         <div class="logo-nba-small nba-small-[i want put abbv here eg phi]"><a>[i want put team name here eg 76ers]</a></div>                     </li>                 {/eq}             {/properties}         </ul>    {/teams}    </div> </script> <div id="output3"></div><br />       $(document).ready(function() {     var league2014 = {     "teams": [{         "properties": [{         "years": null,         "name": "conference",         "value": "eastern"         }, {         "years": null,         "name": "abbv",         "value": "phi"         }, {         "years": null,         "name": "numeric",         "value": "20"         }],         "name": "76ers"     }, {         "properties": [{         "years": null,         "name": "conference",         "value": "western"         }, {         "years": null,         "name": "abbv",         "value": "mem"         }, {         "years": null,         "name": "numeric",         "value": "29"         }],         "name": "grizzlies"     }, {         "properties": [{         "years": null,         "name": "conference",         "value": "eastern"         }, {         "years": null,         "name": "abbv",         "value": "was"         }, {         "years": null,         "name": "numeric",         "value": "27"         }],         "name": "wizards"     }]     }         var source3 = $("#league-template2").html();     var compiled3 = dust.compile(source3, "intro3");     dust.loadsource(compiled3);     dust.render("intro3", league2014, function(err, out) {     $("#output3").html(out);     }); }); 

try this:

<div class="conference">  {#teams}   {#properties teamname=name}     {@select key=name}       {@eq value="conference"}         <h3>{value} conference</h3><ul>       {/eq}       {@eq value="numeric"}         <li class="teamname teamdd_{value}">       {/eq}       {@eq value="abbv"}         <div class="logo-nba-small nba-small-{value}"><a>{teamname}</a></div>         </li>       {/eq}     {/select}   {/properties}   </ul> {/teams} </div> 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -