XMLStringWriter.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Generated by CoffeeScript 1.12.7
  2. (function() {
  3. var XMLStringWriter, XMLWriterBase,
  4. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  5. hasProp = {}.hasOwnProperty;
  6. XMLWriterBase = require('./XMLWriterBase');
  7. module.exports = XMLStringWriter = (function(superClass) {
  8. extend(XMLStringWriter, superClass);
  9. function XMLStringWriter(options) {
  10. XMLStringWriter.__super__.constructor.call(this, options);
  11. }
  12. XMLStringWriter.prototype.document = function(doc, options) {
  13. var child, i, len, r, ref;
  14. options = this.filterOptions(options);
  15. r = '';
  16. ref = doc.children;
  17. for (i = 0, len = ref.length; i < len; i++) {
  18. child = ref[i];
  19. r += this.writeChildNode(child, options, 0);
  20. }
  21. if (options.pretty && r.slice(-options.newline.length) === options.newline) {
  22. r = r.slice(0, -options.newline.length);
  23. }
  24. return r;
  25. };
  26. return XMLStringWriter;
  27. })(XMLWriterBase);
  28. }).call(this);