提交 bb7f0842 编写于 作者: L leon.shi

update docs

上级 fbc9780e
......@@ -52,7 +52,7 @@ function simpleTemplating(data) {
}
```
Calling:
Call:
```js
$('#pagination-container').pagination({
......@@ -64,18 +64,20 @@ $('#pagination-container').pagination({
})
```
To make it easier to maintain, you'd better use specialized templating engine to rendering data.
To make it easier to maintain, you'd better use specialized templating engine to rendering data. Such as [Handlebars](http://handlebarsjs.com/) and [Undercore.template](http://underscorejs.org/#template).
Below is an example using [undercore.template](http://underscorejs.org/#template):
Fresh examples:
## Handlebars
HTML:
```html
<script type="text/template" id="template-demo">
<ul>
<% for (var i = 0, len = data.length; i < len; i++) { %>
<li><%= data[i] %></li>
<% } %>
{{#each data}}
<li>{{this}}</li>
{{/each}}
</ul>
</script>
```
......@@ -86,7 +88,7 @@ JS:
$('#pagination-container').pagination({
dataSource: [1, 2, 3, 4, 5, 6, 7, ... , 195],
callback: function(data, pagination) {
var html = _.template($('#template-demo').html(), {
var html = Handlebars.compile($('#template-demo').html(), {
data: data
});
$('#data-container').html(html);
......@@ -94,16 +96,16 @@ $('#pagination-container').pagination({
})
```
Using [Handlebars](http://handlebarsjs.com/):
## Underscore
HTML:
```html
<script type="text/template" id="template-demo">
<ul>
{{#each data}}
<li>{{this}}</li>
{{/each}}
<% for (var i = 0, len = data.length; i < len; i++) { %>
<li><%= data[i] %></li>
<% } %>
</ul>
</script>
```
......@@ -114,7 +116,7 @@ JS:
$('#pagination-container').pagination({
dataSource: [1, 2, 3, 4, 5, 6, 7, ... , 195],
callback: function(data, pagination) {
var html = Handlebars.compile($('#template-demo').html(), {
var html = _.template($('#template-demo').html(), {
data: data
});
$('#data-container').html(html);
......@@ -122,7 +124,7 @@ $('#pagination-container').pagination({
})
```
Or any other templating engine what you prefer.
Or any other templating engine you prefer.
# License
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册