No Description

XMLWriterBase.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // Generated by CoffeeScript 1.12.7
  2. (function() {
  3. var XMLWriterBase,
  4. hasProp = {}.hasOwnProperty;
  5. module.exports = XMLWriterBase = (function() {
  6. function XMLWriterBase(options) {
  7. var key, ref, ref1, ref2, ref3, ref4, ref5, ref6, value;
  8. options || (options = {});
  9. this.pretty = options.pretty || false;
  10. this.allowEmpty = (ref = options.allowEmpty) != null ? ref : false;
  11. if (this.pretty) {
  12. this.indent = (ref1 = options.indent) != null ? ref1 : ' ';
  13. this.newline = (ref2 = options.newline) != null ? ref2 : '\n';
  14. this.offset = (ref3 = options.offset) != null ? ref3 : 0;
  15. this.dontprettytextnodes = (ref4 = options.dontprettytextnodes) != null ? ref4 : 0;
  16. } else {
  17. this.indent = '';
  18. this.newline = '';
  19. this.offset = 0;
  20. this.dontprettytextnodes = 0;
  21. }
  22. this.spacebeforeslash = (ref5 = options.spacebeforeslash) != null ? ref5 : '';
  23. if (this.spacebeforeslash === true) {
  24. this.spacebeforeslash = ' ';
  25. }
  26. this.newlinedefault = this.newline;
  27. this.prettydefault = this.pretty;
  28. ref6 = options.writer || {};
  29. for (key in ref6) {
  30. if (!hasProp.call(ref6, key)) continue;
  31. value = ref6[key];
  32. this[key] = value;
  33. }
  34. }
  35. XMLWriterBase.prototype.set = function(options) {
  36. var key, ref, value;
  37. options || (options = {});
  38. if ("pretty" in options) {
  39. this.pretty = options.pretty;
  40. }
  41. if ("allowEmpty" in options) {
  42. this.allowEmpty = options.allowEmpty;
  43. }
  44. if (this.pretty) {
  45. this.indent = "indent" in options ? options.indent : ' ';
  46. this.newline = "newline" in options ? options.newline : '\n';
  47. this.offset = "offset" in options ? options.offset : 0;
  48. this.dontprettytextnodes = "dontprettytextnodes" in options ? options.dontprettytextnodes : 0;
  49. } else {
  50. this.indent = '';
  51. this.newline = '';
  52. this.offset = 0;
  53. this.dontprettytextnodes = 0;
  54. }
  55. this.spacebeforeslash = "spacebeforeslash" in options ? options.spacebeforeslash : '';
  56. if (this.spacebeforeslash === true) {
  57. this.spacebeforeslash = ' ';
  58. }
  59. this.newlinedefault = this.newline;
  60. this.prettydefault = this.pretty;
  61. ref = options.writer || {};
  62. for (key in ref) {
  63. if (!hasProp.call(ref, key)) continue;
  64. value = ref[key];
  65. this[key] = value;
  66. }
  67. return this;
  68. };
  69. XMLWriterBase.prototype.space = function(level) {
  70. var indent;
  71. if (this.pretty) {
  72. indent = (level || 0) + this.offset + 1;
  73. if (indent > 0) {
  74. return new Array(indent).join(this.indent);
  75. } else {
  76. return '';
  77. }
  78. } else {
  79. return '';
  80. }
  81. };
  82. return XMLWriterBase;
  83. })();
  84. }).call(this);