Sha256: 27be7eb35bf479bffcfe97897a5f9f9d4bb191cde7b651fc7a84d5b507b70dba

Contents?: true

Size: 650 Bytes

Versions: 8

Compression:

Stored size: 650 Bytes

Contents

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

// http://haml.info/docs/yardoc/file.REFERENCE.html#inserting-ruby-
const 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("=");
  }

  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-0.20.0 src/haml/nodes/script.js
prettier-0.19.1 src/haml/nodes/script.js
prettier-0.19.0 src/haml/nodes/script.js
prettier-0.18.2 src/haml/nodes/script.js
prettier-0.18.1 src/haml/nodes/script.js
prettier-0.18.0 src/haml/nodes/script.js
prettier-0.17.0 src/haml/nodes/script.js
prettier-0.16.0 src/haml/nodes/script.js