Mustache Usage Summary

Source: Internet
Author: User

Objective:

In the analysis of the Jeesite project, saw the mustache, so checked the next

Body:

1. Mustache Overview

Mustache is a JavaScript-based template engine for rendering foreground pages, lightweight, easy to use syntax

2. How to use Mustache

1) Download Mustache.js and Jquery.js (get on Git hub) online, and introduce it in the page

2) Simple Object binding display

    Code Show:

<script>$ (function () {    = {name: "Panie", Age:25,sex: "Girl"};     = "My name is {{name}},i ' m {{age}},sex}}";     = Mustache.render (template,user);    $ ("#userinfo"). HTML (view);}); </script>

    Page Rendering Effect:

Syntax Explanation:

I. Mustache's syntax is simple, use two curly braces to mark the field you want to bind to, "{{}}";

II. The field name within the curly braces is the same as the property name of the object in the second argument in the Mustache.render method

III. The main rendering method is Mustache.render, the method has two parameters, the first is to render the template, that is, the template in the above example, the second is the data source is the user object in the above example

Reference Link: http://blog.csdn.net/xuemoyao/article/details/17896203

Mustache Usage Summary

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.