Sha256: dbd4e0791533d3d58cb1d3d33ce91d551ab4e89124c94f9069f673c9f09dc77f

Contents?: true

Size: 804 Bytes

Versions: 2

Compression:

Stored size: 804 Bytes

Contents

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

// http://haml.info/docs/yardoc/file.REFERENCE.html#running-ruby--
const silentScript = (path, opts, print) => {
  const { children, value } = path.getValue();
  const parts = [`- ${value.text.trim()}`];

  if (children.length > 0) {
    const scripts = path.map(print, "children");

    if (value.keyword === "case") {
      parts.push(
        join(
          "",
          scripts.map((script, index) => {
            const concated = concat([hardline, script]);

            return index % 2 === 0 ? concated : indent(concated);
          })
        )
      );
    } else {
      parts.push(indent(concat([hardline, join(hardline, scripts)])));
    }
  }

  return group(concat(parts));
};

module.exports = silentScript;

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
prettier-0.17.0 src/haml/nodes/silentScript.js
prettier-0.16.0 src/haml/nodes/silentScript.js