Hi all!
Impressed by micro-template engine written by John Resig, I've been created this templates variant:
Few examples:
- // Simple
- {% for (var i=0;i<100;i++) { %}
- <div id="{%= i %}"></div>
- {% } %}
- // With shorthands
- {%@ func(abc) { %}
- {%= abc %}
- {% } %}
- {% func("hello world!"); %}
- // Other features
- {%@ button(value) { %}
- {%= $('<button>'+value+'</button>').click(function() {
- alert(value);
- }) %}
- {% } %}
- {% button("text"); %}
Also this engine can have named templates and can easily call it from other template (see demos).
And my templates can have optional variables, so you won't see errors like: "undefined variable VALUE" (with some restrictions, of course).
Thanks for reading, will be glad to see your opinion here in replies