Sha256: 0773c0611243b6e2096d1263cda047f9f26349238382492113b90b43f52070b7

Contents?: true

Size: 594 Bytes

Versions: 8

Compression:

Stored size: 594 Bytes

Contents

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

// http://haml.info/docs/yardoc/file.REFERENCE.html#haml-comments--
const 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-0.20.0 src/haml/nodes/hamlComment.js
prettier-0.19.1 src/haml/nodes/hamlComment.js
prettier-0.19.0 src/haml/nodes/hamlComment.js
prettier-0.18.2 src/haml/nodes/hamlComment.js
prettier-0.18.1 src/haml/nodes/hamlComment.js
prettier-0.18.0 src/haml/nodes/hamlComment.js
prettier-0.17.0 src/haml/nodes/hamlComment.js
prettier-0.16.0 src/haml/nodes/hamlComment.js