Tinytemplate template engine hot-baked, officially open source

Source: Internet
Author: User

Wading in the template engine area is purely careless.
I would like to express our strong thanks and tribute to the following people:
@sub Jetbrick Author
@sept
@webit Webit Author
@ Rogrun Rythm Author
@ idle. Da Fu beetl author
And many, though not listed, have helped me when I wrote Tinytemplate.

Preface
Originally did not write a template engine of the plan, because according to my understanding, has always considered this "language" level of the engine, the difficulty is very large. Always feel that their level is not enough, so I do not dare to have this idea. Until a large number of use of velocty, encountered velocty a lot of unsatisfactory place, but also helpless, back to the JSP, and heart not gan. Therefore, it is expected to find a grammatical structure close to velocty, but there is no velocity of these inconvenient template language. So into a template language group, a group of big boys are at least a template language of the author, so the author in the inside expressed their expectations, the big boys have introduced their own template engine, so the author one by one to see the source code, look at the document. Say the actual, look at the document, feel very good, have their own characteristics, look at the grammar is also good, in addition to some of their own special attention to the point is not outside, the other parts are very good. But the distance from their own demand or there is a gap, how to do? So we are going to find a closest template engine to carry out a certain extension, pick to pick the Jetbrick this template language.
The reason why I chose this is because of the following reasons:
1.ANTLR lexical and grammar file writing is very clear, for me this ANTLR blind, can also understand, and even can divert modify, this is very important, in the late to make when the grammatical improvement, this shows the advantages of
2. Good code quality, using sonar for analysis, the results are quite good, in all the template language that the author has seen, counted as the choice
3. The grammatical structure is very close to velocity, which is very important to me, because my idea is that the velocity syntax is quite acceptable, close to velocity syntax, and some users of velocity can easily switch
4. The test case is perfect, after the tiny template engine is completed, testing with its test cases has found several bugs, which is very effective
5. Easy to build environment, directly download the source code, you can install the success, you can run test cases
OK, pick also picked, choose also selected, began to write Tinytemplate, let's go.
Three days of preliminary writing, and spent a week to improve, test, documentation, so the students see the Tinytemplate

Overview
Tiny template engine is a Java technology-based template engine, it has a small volume, high performance and expansion of the characteristics of easy. Suitable for all scenarios that generate text type content through text templates, such as XML, source files, HTML, and so on, it can be said that it appears to replace the velocity template engine, so that on the instruction set as far as possible with the velocity of the same time, Also expanded some of the velocity does not solve the problem of the command and function, in the expression of many aspects as far as possible with the Java consistency, so it is easy to learn to use.
1. Small volume performance in a total of less than 4000 lines of code, remove the parser nearly 1000 lines, the core engine only not 3000 lines of code
2. High performance in the current domestic several high-performance template engine such as: Jetbrick, Webit and other engine performance compared to nearly about, but compared to velocity, freemarker and so on have made great progress, efficiency is roughly four times times the velocity
3. Extensibility performance in all environments of the tiny framework engine can be self-expanding, and with the original system of Good unity
4. Easy-to-learn performance in tiny framework concept, Module Division science, with very high high cohesion and low coupling
5. Flexible use of the table now, can be multiple cases, a single case, and can be well integrated with spring, etc.
Brief feature Introduction
• Similar to Velocity instructions, the same or similar instructions up to about 90%
• Support for static compilation
• Support for compilation caching
• Hot Load Support
• Variable parameter method invocation support
• Support for class member method overloading
• Support for function extensions
• Using weakly typed methods, the template layer code is less constrained, how the model layer changes, the template layer code adjustment is very easy
• Supports macro definition #macro
• Support layout layouts

Performance
The tiny template engine is compiled and executed, so it is much faster than the first-generation template engines such as velocity and freemarker. However, due to the use of weak type, the stronger type will be slightly slower, the performance difference of about 5%, can be negligible.

1.png (16.42 KB, download number: 0)

Download attachments

2015-5-26 22:40 Upload



The above data is measured on the same computer.

template engine name performance features
Velocity 4 + times Velocity has features, all supported, and a lot of new features expanded
Freemarker 5 + times said that the actual use is not too much, so the function is inconvenient to say, theoretically certainly many more functions
Jetbrick performance slightly less than 3% tiny use weak type, jetbrick with strong type, Jetbrick additional function function is more, tiny expands some new function, Tiny is learning J Etbrick on the basis of the above.
HTTL performance slightly weaker 1% tiny use weak type, HTTL use strong type, function aspect tiny expand many function that compensate velocity insufficiency.
beetl performance is roughly about 1.9 times times features tiny template engine is naturally strong, but its market application is better, the basic function provides more.
Several other performance comparisons See features without in-depth understanding and therefore cannot be judged.


At present, the robustness of tinytemplate is not good enough and is being tested.
Document Address:
tinygroup.org Portal->document
Development environment Construction:
Download the tiny Foundation project and install it first:
Https://git.oschina.net/tinyframework/tiny
If there is a problem during the install process, please compare the FAQ
http://my.oschina.net/tinyframework/blog/206718
Source Address:
Https://git.oschina.net/tinyframework/TinyTemplate

Tinytemplate template engine hot-baked, officially open source

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.