📜 ⬆️ ⬇️

jQuery template engine

It all started with reading this post here .
I really liked the idea, and without thinking twice, I began to search the Internet for ready-made solutions of “template engines” for jQuery.

Here is what I managed to find:


Short about found


jQuery templates is a simple and intuitive plugin that replaces expressions of the form ${myvar:func1:func2} with the values ​​passed by the input parameters.
Nano - does almost the same thing, but the plug-in code takes five lines.
Pure - “DOM-based” template engine; in fact, all substitutions are due to the imposition of object data on the dom-tree.
jQote - as they themselves state - is rewritten under the jQuery “Micro Template Engine”.
jTemplates - a rather interesting engine with great functionality (thanks to spanasik )

JQuery templates


On the jQuery forums, there was a rather active discussion on the topic of incorporating the template engine into the jQuery core ( link ).
In particular, a demo version was offered, written by John Resig ( link )
')

My template engine


In my opinion, the most successful of template engines is jquery-tmpl (although it is a demonstration one). But I didn’t really like its implementation, plus I lacked some methods.

Therefore, I decided to rewrite it and add a small functionality (plus write a demo that would show the possibility of using templates).

Result


The result of the work can be downloaded here: jQuery.tpl , all the sources are: Google code .

And here's the demo page .

Main features




I will be glad to criticism and comments.

PS
Works under IE6

Source: https://habr.com/ru/post/91253/


All Articles