JavaScript Template Library Jsrender for loop nesting example

Source: Internet
Author: User

Recently in the framework of integrating the front end, we know that one of the most powerful templating engines of JavaScript is jsrender, the standard implementation of the next-generation jquery template engine.

Usually in the template merge process, we encounter two or even three levels of nesting situation, the powerful jsrender will naturally support, as follows:

<! DOCTYPE html>    {{ for#data}}         {{ forLanguage}} <li>{{: #parent. Parent.data.name}} is learning {: title}}<br/> {{ forscores}} <a href= "#" >{{:score}}</a> {{/for}} </li> {{/for}} </ul> {{ /for}}</script><script type= "Text/javascript" >varStudents = [{name: "Zhang San", Language:[{title: "Medium", Scores:[{score:12},{score:13},{score:14}]},{title: "English", Scores:[{score : 12},{score:13},{score:14}]},{title: "Number", scores:[{score:12},{score:13},{score:14}]}]}, {name:"John Doe", Language:[{title: "Zhong", Scores:[{score:12},{score:13},{score:14}]},{title: "Zhong", scores:[{score:12},{score:13}, {score:14}]},{title: "Medium", scores:[{score:12},{score:13},{score:14}]}]}, {name:"Harry", Language:[{title: "Zhong", Scores:[{score:12},{score:13},{score:14}]},{title: "Zhong", scores:[{score:12},{score:13}, {score:14}]},{title: "Medium", scores:[{score:12},{score:13},{score:14}]}]}]; $("#studentList"). HTML ($ ("#studentTemplate"). Render (students));</script></body>

The effect is as follows:

JavaScript Template Library Jsrender for loop nesting example

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.