00001
00002 (function() {
00003 var XMLProcessingInstruction, create;
00004
00005 create = require('lodash/create');
00006
00007 module.exports = XMLProcessingInstruction = (function() {
00008 function XMLProcessingInstruction(parent, target, value) {
00009 this.stringify = parent.stringify;
00010 if (target == null) {
00011 throw new Error("Missing instruction target");
00012 }
00013 this.target = this.stringify.insTarget(target);
00014 if (value) {
00015 this.value = this.stringify.insValue(value);
00016 }
00017 }
00018
00019 XMLProcessingInstruction.prototype.clone = function() {
00020 return create(XMLProcessingInstruction.prototype, this);
00021 };
00022
00023 XMLProcessingInstruction.prototype.toString = function(options, level) {
00024 var indent, newline, offset, pretty, r, ref, ref1, ref2, space;
00025 pretty = (options != null ? options.pretty : void 0) || false;
00026 indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' ';
00027 offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0;
00028 newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n';
00029 level || (level = 0);
00030 space = new Array(level + offset + 1).join(indent);
00031 r = '';
00032 if (pretty) {
00033 r += space;
00034 }
00035 r += '<?';
00036 r += this.target;
00037 if (this.value) {
00038 r += ' ' + this.value;
00039 }
00040 r += '?>';
00041 if (pretty) {
00042 r += newline;
00043 }
00044 return r;
00045 };
00046
00047 return XMLProcessingInstruction;
00048
00049 })();
00050
00051 }).call(this);