NodeList.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. Copyright (c) 2004-2012, The Dojo Foundation All Rights Reserved.
  3. Available via Academic Free License >= 2.1 OR the modified BSD license.
  4. see: http://dojotoolkit.org/license for details
  5. */
  6. if(!dojo._hasResource["dojox.dtl.ext-dojo.NodeList"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
  7. dojo._hasResource["dojox.dtl.ext-dojo.NodeList"] = true;
  8. dojo.provide("dojox.dtl.ext-dojo.NodeList");
  9. dojo.require("dojox.dtl._base");
  10. dojo.extend(dojo.NodeList, {
  11. dtl: function(template, context){
  12. // template: dojox.dtl.__StringArgs|String
  13. // The template string or location
  14. // context: dojox.dtl.__ObjectArgs|Object
  15. // The context object or location
  16. var d = dojox.dtl;
  17. var self = this;
  18. var render = function(template, context){
  19. var content = template.render(new d._Context(context));
  20. self.forEach(function(node){
  21. node.innerHTML = content;
  22. });
  23. }
  24. d.text._resolveTemplateArg(template).addCallback(function(templateString){
  25. template = new d.Template(templateString);
  26. d.text._resolveContextArg(context).addCallback(function(context){
  27. render(template, context);
  28. });
  29. });
  30. return this;
  31. }
  32. });
  33. }