Template address: https://github.com/zhangshaolong/simplite Welcome to express valuable opinions and contribution codes. Features:
1: Small code volume and low learning cost;
2: The default jsp syntax tagging method is used. Friends who are familiar with jsp can write templates directly according to jsp's syntax;
3: Use native js syntax for logical processing. As long as you are familiar with js syntax, you can get started directly, without learning costs.
4: Supports all syntax of native js as code logic snippets and supports a wide writing format.
5: Supports redefining the tag characters of the template language. The default logical tags are <% and %>, and the default attribute tags are <%= and %>.
6: Support nested sub-templates. The sub-template defaults (no data parameters passed) are shared by sharing parent template data. You can set the data set used by the sub-template by passing parameters.
7: Support dynamic import of templates and embedding multiple templates. As long as the imported template is not a circular dependency template, it can be handled normally.
8: Support sub-templates to use the fields specified by Simplite.dataKey to access the passed data set. The default value is "_this". For data sets such as arrays and numbers, it is easy to get data using Simplite.dataKey.
9: Support object-oriented mode to manually organize template processing using templates and pure static functions.
10: In addition to accessing parent template data, it can also provide any data in the scope of the method as a data set. For example, there is an arr globally, so you can include (tmplt, arr)
grammar:
It can be seen that when using include, you can use sub-templates and pass in the specified data set as the data source. For complex multi-layer structures, it can well control the data structure of each template.