Inline.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. define("dojox/dtl/Inline", [
  2. "dojo/_base/lang",
  3. "./_base",
  4. "dijit/_WidgetBase",
  5. "dojo/query" // dojo.query
  6. ], function(lang,dd,Widget,Query){
  7. /*=====
  8. Widget = dijit._WidgetBase;
  9. Query = dojo.query;
  10. dd = dojox.dtl;
  11. =====*/
  12. dd.Inline = lang.extend(function(args, node){
  13. this.create(args, node);
  14. },
  15. Widget.prototype,
  16. {
  17. context: null,
  18. render: function(/*Object|dojox.dtl.Context?*/ context){
  19. this.context = context || this.context;
  20. this.postMixInProperties();
  21. Query("*", this.domNode).orphan();
  22. this.domNode.innerHTML = this.template.render(this.context);
  23. },
  24. declaredClass: "dojox.dtl.Inline",
  25. buildRendering: function(){
  26. var div = this.domNode = document.createElement("div");
  27. var node = this.srcNodeRef;
  28. if(node.parentNode){
  29. node.parentNode.replaceChild(div, node);
  30. }
  31. this.template = new dd.Template(lang.trim(node.text), true);
  32. this.render();
  33. },
  34. postMixInProperties: function(){
  35. this.context = (this.context.get === dd._Context.prototype.get) ? this.context : new dd._Context(this.context);
  36. }
  37. });
  38. return dojox.dtl.Inline;
  39. });