comment.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*!
  2. * Stylus - Comment
  3. * Copyright (c) Automattic <developer.wordpress.com>
  4. * MIT Licensed
  5. */
  6. /**
  7. * Module dependencies.
  8. */
  9. var Node = require('./node');
  10. /**
  11. * Initialize a new `Comment` with the given `str`.
  12. *
  13. * @param {String} str
  14. * @param {Boolean} suppress
  15. * @param {Boolean} inline
  16. * @api public
  17. */
  18. var Comment = module.exports = function Comment(str, suppress, inline){
  19. Node.call(this);
  20. this.str = str;
  21. this.suppress = suppress;
  22. this.inline = inline;
  23. };
  24. /**
  25. * Inherit from `Node.prototype`.
  26. */
  27. Comment.prototype.__proto__ = Node.prototype;
  28. /**
  29. * Return a JSON representation of this node.
  30. *
  31. * @return {Object}
  32. * @api public
  33. */
  34. Comment.prototype.toJSON = function(){
  35. return {
  36. __type: 'Comment',
  37. str: this.str,
  38. suppress: this.suppress,
  39. inline: this.inline,
  40. lineno: this.lineno,
  41. column: this.column,
  42. filename: this.filename
  43. };
  44. };
  45. /**
  46. * Return comment.
  47. *
  48. * @return {String}
  49. * @api public
  50. */
  51. Comment.prototype.toString = function(){
  52. return this.str;
  53. };