Home >Web Front-end >JS Tutorial >JsRender practical introductory tutorial_javascript skills
This article is a practical introductory tutorial for JsRender. Examples describe the use of tag else, nested loops to access parent data and other knowledge points. Share it with everyone for your reference. The details are as follows:
Foreword
JsRender is a JavaScript template engine based on jQuery. It has the following features:
· Simple and intuitive
· Powerful function
· Extensible
· Fast as lightning
These features seem very powerful, but almost every template engine will promote them like this. . .
Due to work needs, Xiaocai came into contact with this template engine. After using it for a while, I found that it is indeed relatively powerful, but Xiaocai feels that some parts are too powerful, which makes it difficult to understand.
On the other hand, the official documentation of JsRender is relatively detailed, but there is surprisingly little other information. If you encounter any problems, you basically can’t find them. Not only can’t you find relevant issues, but there are almost no results.
In addition, some parts of JsRender are really difficult to understand, so Xiaocai urgently needs to share some "best practices".
Based on recent use, Xiaocai has summarized some practical experiences. Of course, these experiences cannot be found in official documents.
Nested loops use #parent to access parent data (not recommended)
序号 | 姓名 | 家庭成员 |
---|
Nested loops use parameters to access parent data (recommended)
serial number |
---|
Use else in custom tag (strongly not recommended)
名称 | 单价 |
---|
Use helper instead of custom tags (recommended)
名称 | 单价 |
---|
I hope this article will be helpful to everyone’s learning of JsRender programming.