Simple Introduction to simple js template engine simplite_javascript class library

Source: Internet
Author: User
This article mainly introduces the introduction and usage of simple js template engine simplite. For more information, see https://github.com/zhangshaolong/simplitewelcome. 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.

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.