Sha256: db0e5a74d8bc06721910d99272be3b7263cb19538a8b87c0f8287ac1d4f23d3d

Contents?: true

Size: 591 Bytes

Versions: 8

Compression:

Stored size: 591 Bytes

Contents

const { concat, hardline, indent, join } = require("../../prettier");

// https://haml.info/docs/yardoc/file.REFERENCE.html#haml-comments--
function hamlComment(path, opts, _print) {
  const node = path.getValue();
  const parts = ["-#"];

  if (node.value.text) {
    if (opts.originalText.split("\n")[node.line - 1].trim() === "-#") {
      const lines = node.value.text.trim().split("\n");

      parts.push(indent(concat([hardline, join(hardline, lines)])));
    } else {
      parts.push(" ", node.value.text.trim());
    }
  }

  return concat(parts);
}

module.exports = hamlComment;

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
prettier-1.5.5 src/haml/nodes/hamlComment.js
prettier-1.5.4 src/haml/nodes/hamlComment.js
prettier-1.5.3 src/haml/nodes/hamlComment.js
prettier-1.5.2 src/haml/nodes/hamlComment.js
prettier-1.5.1 src/haml/nodes/hamlComment.js
prettier-1.5.0 src/haml/nodes/hamlComment.js
prettier-1.4.0 src/haml/nodes/hamlComment.js
prettier-1.3.0 src/haml/nodes/hamlComment.js