Simple Introduction to simple js template engine and simple js Template

Source: Internet
Author: User

Simple Introduction to simple js template engine and simple js Template

Template address: https://github.com/zhangshaolong/simplitewelcome comments and contribution code. Features:

1: The amount of code is small, and the learning cost is low;

2: The default jsp syntax TAG method. jsp-related users can directly write templates Based on jsp syntax;

3: use native js syntax for logic processing. As long as you are familiar with js syntax, you can get started directly without learning costs.

4: supports all native js syntaxes as code logic snippets and a broad writing format.

5: Support for redefinition of template Language tags. The default logical tags are <% and %>, and the default attribute tags are <% = and %>.

6: Nested subtemplates are supported. By default (no data parameters are passed), The subtemplates share the parent template data. You can set the dataset used by the subtemplate by passing parameters.

7: supports dynamic import templates and embedding of multiple templates, as long as the imported template is not a circular dependency template, it can be processed normally.

8: supports the use of Simplite in subtemplates. the complete set of data transmitted by the field specified by dataKey. The default value is "_ this". For datasets such as arrays and numbers, use Simplite. dataKey is easy to get data.

9: The template processing process can be manually organized by using templates and pure static functions in object-oriented mode.

10: In addition to accessing the parent template data, you can also provide any data in the method scope as a dataset. For example, if there is an arr globally, you can include (tmplt, arr)

Syntax:

We can see that when using include, you can use a sub-template to input a specified dataset as a data source. For a complex multi-layer structure, you can well control the data structure of each template.

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.