BorisMoore / jquery-tmpl

The original official jQuery Templates plugin. This project was maintained by the jQuery team as an official jQuery plugin. It is no longer in active development, and has been superseded by JsRender.
3.23k stars 1.01k forks source link

Ajax implementation for getting remote templates #58

Closed DanielBaulig closed 13 years ago

DanielBaulig commented 13 years ago

I implemented a getTemplate and the suiting $.ajax({dataType:"template"}) parameter which enables easy template fetching from a remote host. It utilizes the new ajax interface of jQuery 1.5. This however means it requires jQuery 1.5 to function, so you will propably not want to pull it in before starting any jQuery 1.5 based work. I also added an example you might want to check out. However, it's really trivial:

jQuery.getTemplate('/url/to/template', 'nameCompiledTemplateWillGet', function (templateName) {
  // you now have the name of your compiled template in templateNane and can use it, eg:
  jQuery.tmpl(templateName, { replaceMe: 'You where replaced!' }).appendTo('#hook');
}

Maybe it would be nice to actually get the jQuery wrapped compiled template instead of the name, wasn't sure on that.

Best regards, Daniel

ghost commented 13 years ago

Gotta get this on in there.

BorisMoore commented 13 years ago

Yes, thanks. I am also looking at some related ideas for Beta2, and will look at your implementation when I get to that aspect. Definitely on the map to make getting remote templates easier...

rdworth commented 13 years ago

Thanks for taking the time to submit this pull request. Unfortunately this plugin is no longer being actively developed or maintained by the jQuery team. See README for more info.