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.