blueimp/JavaScript-Templates

thank you

Closed this issue · 2 comments

hi blueimp,

i didn't know how else to thank you for making this template plugin so thought i'd just leave the message here. I've always been looking for a simple templating mechanism for JSON data (awesome for $.ajax, success:function(data)!) and this is a huge help!!!

one question, can you tell me what are other ways people render JSON data as HTML? Your templating engine is still quite new and I'm wondering what are common/popular ways people have been dealing with JSON until now.

any thoughts would be greatly appreciated,

thanks,
tim

Thanks for your kind message, Tim!

Actually, my simple templating engine is quite late to the party.
Like many others, it was inspired by John Resig's JavaScript Micro-Templating blog post, which was published more than 3 1/2 years ago in July 2008.

The first JavaScript templating engine I used myself was the jQuery Templates plugin.
As it became clear that it would be discontinued I looked into other solutions and finally decided to write my own:
blueimp/jQuery-File-Upload#780

I don't think that my solution is necessarily the "best" one for every use case.
But I wanted a templating engine that allows to use the full power of JS and doesn't add any language constructs of its own while keeping it super simple and lightweight.

Looping over collections can be a bit cumbersome with a pure JS templating solution, but then again, it's possible to write quite concise looping code like this:

<ul>
{% for (var i=0, file; file=o.files[i]; i++) { %}
    <li>{%=file.name%}</li>
{% } %}
</ul>

If you need a more elegant templating language, I would recommend an implementation like Handlebars.

awesome thanks Blueimp,

as you can probably tell i'm still quite a novice coder but I like your/John Resig's template solution better than handlebars.js. Simple and effective. I have to admit Handlebars and Mustache confuse me big time and seem like too much more trouble to learn, create too much code and seem like couldn't be great for performance for most applications.

I'm likely just not grasping the full power though as the guys behind Handlebars and Mustache seem super smart and those are some very well received libraries on Github.

anyway,thanks again!

tim