JsRender系列demo(5)compline

來源:互聯網
上載者:User

標籤:style   blog   http   java   os   io   for   cti   

<!DOCTYPE html><html><head><script src="http://code.jquery.com/jquery.js" type="text/javascript"></script><script src="../../jsrender.js" type="text/javascript"></script> <link href="../resources/demos.css" rel="stylesheet" type="text/css" /></head><body><a href="../demos.html">JsRender Demos</a><br /><h3>Accessing paths</h3><script id="peopleTemplate" type="text/x-jsrender"><b>{{:#index+1}}:</b> {{>firstName}} {{>lastName}}:<br/>{{for address tmpl="#addressTemplate"}}{{else}}Address missing{{/for}}<div>Phones:{{for ~combine(phones, cells)}}<b>{{>#data}}</b> ({{>#parent.parent.data.firstName}}‘s){{else}}{{>#parent.data.firstName}} has no phones or cells{{/for}}{{!-- or provide an alias to get to firstName from nested contentPhones:{{for ~combine(phones, cells) ~frstNm=firstName}}<b>{{>#data}}</b> ({{>~frstNm}}‘s){{else}}{{>~frstNm}} has no phones or cells{{/for}}--}}</div><br/><i>{{>firstName}}{{if address && address.street}}  {{!-- address may be null or undefined --}}lives in {{>address.street}}.{{else}}has no address...{{/if}}</i><hr/></script><script id="addressTemplate" type="text/x-jsrender"><div>{{if street}}{{>street}}{{else}}<i>Somewhere</i> in{{/if}}{{>city}}</div></script><div id="peopleList"></div><script type="text/javascript">var people = [{firstName: "Pete",lastName: "Ruffles",address: {city: "Bellevue"},cells: ["425 666 3455", "425 222 1111"]},{firstName: "Xavier",lastName: "NoStreet",phones: ["222 666 3455"],cells: ["444 666 3455", "999 222 1111"]},{firstName: "Christie",lastName: "Sutherland",address: {street: "222 2nd Ave NE",city: "Redmond"}}];$.views.tags({notLast: function( content ) {var array = this.parent.data;return array[ array.length - 1 ] === this.data ? "" : content( this );}});$.views.helpers({combine: function( arr1, arr2 ) {return arr1 && arr2 ? arr1.concat(arr2) : arr1 || arr2;}});$( "#peopleList" ).html($( "#peopleTemplate" ).render( people ));</script></body></html>

  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.