Sha256: 381127e515e9aea2676a7a78d189ad93a2d047a6d8fdaa9fa3fd910cd8ce57c0

Contents?: true

Size: 783 Bytes

Versions: 8

Compression:

Stored size: 783 Bytes

Contents

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

// https://haml.info/docs/yardoc/file.REFERENCE.html#inserting_ruby
function script(path, opts, print) {
  const { children, value } = path.getValue();
  const parts = [];

  if (value.escape_html) {
    parts.unshift("&");
  }

  if (value.preserve) {
    parts.push("~");
  } else if (!value.interpolate) {
    parts.push("=");
  }

  if (value.escape_html && !value.preserve && value.interpolate) {
    parts.push(" ", value.text.trim().slice(1, -1));
  } else {
    parts.push(" ", value.text.trim());
  }

  if (children.length > 0) {
    parts.push(
      indent(concat([hardline, join(hardline, path.map(print, "children"))]))
    );
  }

  return group(concat(parts));
}

module.exports = script;

Version data entries

8 entries across 8 versions & 1 rubygems

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